MainActivity 在退出时调用onDestroy方法
public void onDestroy() {
super.onDestroy();
if (mBluetoothReceiver != null) {
unregisterReceiver(mBluetoothReceiver);
}
mBluetoothService.stop();
}
stop()方法是BluetoothService 中的。
public synchronized void stop() {
if (D)
Log.d(TAG, "------------service.stop");
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}
问题是 在stop方法中报了source not found 的异常。但奇怪的是stop方法执行了两遍,第一次ok,第二次报错了。

------解决思路----------------------
1.先看看放到里面,应该只会执行一次。
2.放在外面,前面加一个mBluetoothService是状态查看。
应该是service的问题。