How to solve the BluetoothGatt : android.os.DeadObjectException error happened in Android?

前端 未结 4 2085
北恋
北恋 2021-02-13 18:07

I following the page Bluetooth Low Energy for developing in Android 4.3 for Bluetooth Low Energy .

I already can turn on the Bluetooth

4条回答
  •  半阙折子戏
    2021-02-13 18:27

    My workaround to the problem was to delay the reconnection:

    private void connectGatt(final String address) {
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                bluetoothGatt = bluetoothManager.getAdapter().getRemoteDevice(address).connectGatt(context, true, bluetoothGattCallback);
            }
        }, 500);
    }
    

提交回复
热议问题