2017-11-15 26 views
0

接続デバイスがBluetoothデバイスの情報を取得しないようにするため、Bluetooth接続デバイスをすべて保存します。デバイスの再起動時にAndroidペアリングされたBluetoothが消える

しかし、他のデバイスは予想どおりに動作しますが、1つのタイプのBluetoothデバイスは、電話機を再起動するとペア情報を失います。

なぜこのようなことが起こるか知っていますか、またはスキャンせずにBluetoothデバイス情報を取得する別の方法がありますか?

答えて

0

BluetoothAdapterを使用できます。

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

// TODO your code 

Bluetoothデバイスが周りにいない場合は、BluetoothGattCallback年代にonConnectionStateChangeBluetoothGatt.STATE_DISCONNECTEDを報告します。

BluetoothDeviceの作成者にはパッケージスコープがあります。しかし、BluetoothAdapterのgetRemoteDeviceのソースコードは、

public BluetoothDevice getRemoteDevice(String address) { 
    return new BluetoothDevice(address); 
} 
です。
関連する問題