我正在尝试将我的 android 应用程序连接到 MS Band,但出现以下错误:
java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.microsoft.band.service.action.BIND_BAND_SERVICE }
我使用的代码片段如下:
private View.OnClickListener mButtonConnectClickListener = new View.OnClickListener() {
@Override
public void onClick(View button) {
pairedBands = BandClientManager.getInstance().getPairedBands();
bandClient = BandClientManager.getInstance().create(getApplicationContext(), pairedBands[0]);
// Connect must be called on a background thread.
new ConnectTask().execute();
}
};
private class ConnectTask extends AsyncTask<BandClient, Void, Void> {
@Override
protected Void doInBackground(BandClient... clientParams) {
BandPendingResult<ConnectionResult> pendingResult = null;
try {
pendingResult = bandClient.connect();
} catch (BandIOException e) {
e.printStackTrace();
}
try {
ConnectionResult result = pendingResult.await();
if(result == ConnectionResult.OK) {
BandConnection.setText("Connection Worked");
} else {
BandConnection.setText("Connection Failed");
}
} catch(InterruptedException ex) {
// handle InterruptedException
} catch(BandException ex) {
// handle BandException
}
return null;
}
protected void onPostExecute(Void result) {
}
}
我正在遵循Microsft Band SDK中给出的示例,我对此并不陌生。任何帮助将不胜感激。