【发布时间】:2015-04-09 18:27:10
【问题描述】:
我正在尝试将我的 android 应用程序连接到 MS Band,但出现以下错误:
java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.microsoft.band.service.action.BIND_BAND_SERVICE }
我使用的代码sn-p如下:
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 中给出的示例进行操作,我对此并不陌生。任何帮助将不胜感激。
【问题讨论】:
-
我讨厌成为坏消息的承担者,但看起来微软没有更新他们的 sdk 以兼容 android 5.0。在 5.0 中,你不能再做隐式意图,这就是 sdk 在某处所做的事情。他们需要更新 sdk
标签: android android-intent android-5.0-lollipop illegalargumentexception microsoft-band