我正在尝试启动服务
Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
startActivity(gattServiceIntent);
但是我收到以下消息
07-14 20:58:13.296: E/AndroidRuntime(21311): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.rcfun.blecar/com.rcfun.blecar.util.BluetoothLeService}; have you declared this activity in your AndroidManifest.xml?
我试图声明如下
<service
android:name=".BluetoothLeService"
android:enabled="true">
</service>
和
<service
android:name="com.rcfun.blecar.util.BluetoothLeService"
android:enabled="true">
</service>
但是这两个声明都给出了与我上面提到的相同的错误。
答案 0 :(得分:2)
将startActivity(gattServiceIntent);
替换为startService(gattServiceIntent);
。
答案 1 :(得分:0)
试试这个:
bindService(new Intent(this,BluetoothLeService.class),mServiceConnection,Context.BIND_AUTO_CREATE);