0
votes

I want the connected device to get BluetoothDevice device information without scanning Bluetooth, so I store all Bluetooth-connected devices.

However, while other devices behave as expected, one type of Bluetooth devices will lose their paired information when the phone is rebooted.

Do anyone know why this may happen or have an alternative way to obtain Bluetooth Device information without scanning?

1

1 Answers

0
votes

You can use BluetoothAdapter.

BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(mac);
device.connectGatt(mContext, false, mGattCallback);

// TODO your code

If the bluetooth device is not around, in BluetoothGattCallback's onConnectionStateChange will report BluetoothGatt.STATE_DISCONNECTED.

BluetoothDevice's creator has packages scope. But the source code of BluetoothAdapter's getRemoteDevice is:

public BluetoothDevice getRemoteDevice(String address) {
    return new BluetoothDevice(address);
}