Bluebooth使用了很长时间,它无法使用。当我禁用蓝牙时,一段时间后,它会自动打开。 错误打印信息:
05-05 06:28:25.814: E/BTIF_CORE(5554): btif_disable_bluetooth : not yet enabled
05-05 06:28:33.819: E/BluetoothAdapterState(5554): Error disabling Bluetooth
05-05 06:28:33.855: E/PRX(628): hard code service registered.
05-05 06:28:33.874: E/BluetoothServiceJni(5554): SOCK FLAG = 1 ***********************
05-05 06:28:33.874: E/(5554): btmtk_jsr82_session_service_registration@264:[JSR82][JBT] JSR82 does not init
05-05 06:28:33.874: E/BluetoothServiceJni(5554): Socket listen failed: 1
05-05 06:28:33.874: E/BluetoothAdapterService(1112665360)(5554): Failed to create socket channel
05-05 06:28:33.874: E/[MAP]BluetoothMapService(5554): [initSocket] Error create RfcommServerSocket java.io.IOException: Error: -1
05-05 06:28:33.922: E/BluetoothServiceJni(5554): SOCK FLAG = 1 ***********************
05-05 06:28:33.922: E/(5554): btmtk_jsr82_session_service_registration@264:[JSR82][JBT] JSR82 does not init
05-05 06:28:33.922: E/BluetoothServiceJni(5554): Socket listen failed: 1
05-05 06:28:33.923: E/BluetoothAdapterService(1112665360)(5554): Failed to create socket channel
05-05 06:28:33.923: E/BluetoothPbapService(5554): Error create RfcommServerSocket java.io.IOException: Error: -1
05-05 06:28:33.982: E/BluetoothReceiver(1042): [MMI][BluetoothReceiver.startService][start service [com.mediatek.bluetooth.AdvancedService]
05-05 06:28:33.994: E/BluetoothServiceJni(5554): SOCK FLAG = 0 ***********************
05-05 06:28:33.994: E/(5554): btmtk_jsr82_session_service_registration@264:[JSR82][JBT] JSR82 does not init
答案 0 :(得分:0)
BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter to = bluetoothManager.getAdapter();
isServiceRestart = true;
if(to.isEnabled()) {
to.disable();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
to.enable();
} else if(!to.isEnabled()) {
to.enable();
}
答案 1 :(得分:0)