当你收到错误
SCAN_FAILED_APPLICATION_REGISTRATION_FAILED
您应该禁用BluetoothAdapter
BluetoothAdapter.getDefaultAdapter().disable();
禁用BluetoothAdapter,会触发事件STATE_TURNING_OFF.触发此事件后,尝试重新连接到BluetoothAdapter:
case BluetoothAdapter.STATE_OFF:
Log.d(TAG, "bluetooth adapter turned off");
handler.postDelayed(new Runnable() {
@Override
public void run() {
Log.d(TAG, "bluetooth adapter try to enable");
BluetoothAdapter.getDefaultAdapter().enable();
}}, 500);
break;