我是在
Android和BLE开发的.我希望应用程序在BLE设备断开后自动重新连接到BLE设备,但是回到范围和广告中.
我使用以下代码连接到BLE设备:
public void connect(final String address) {
// TODO Auto-generated method stub
Log.w(TAG, "BluetoothLeService Connect function.");
if(mBluetoothAdapter == null || address == null){
Log.w(TAG, "BluetoothAdapter not initialized or unspecified address.");
//return false;
}
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
mBluetoothGatt = device.connectGatt(this, true, mGattCallback);
}
我已将AutoConnect设置为true,但是当BLE设备断开连接并返回范围时,它没有重新连接.
在Android中将autoConnect设置为true时,为什么应用程序不会重新连接到BLE设备?
我错过了什么吗?
提前致谢.