Android 找到外围设备,但可以';我无法连接到它
在我的应用程序中,我可以很好地扫描外围设备,但无法连接到它。以下是连接到主设备的代码:Android 找到外围设备,但可以';我无法连接到它,android,bluetooth-lowenergy,Android,Bluetooth Lowenergy,在我的应用程序中,我可以很好地扫描外围设备,但无法连接到它。以下是连接到主设备的代码: bleGatt = masterDevice.connectGatt(currentContext,false,gattCallback); if(bleGatt == null){ Log.w(TAG,"Unable to create GATT client"); } 如果我将自动连接标志更改为true,如: bleGatt = masterDevice.conn
bleGatt = masterDevice.connectGatt(currentContext,false,gattCallback);
if(bleGatt == null){
Log.w(TAG,"Unable to create GATT client");
}
如果我将自动连接标志更改为true,如:
bleGatt = masterDevice.connectGatt(currentContext,true,gattCallback);
然后设备会连接,但我的自定义服务和特征不会在ServicesDiscoveryd回调中被发现。我认为这段代码在API大于21的设备上运行有一些问题
任何帮助都将不胜感激,谢谢 运气好吗?有时我可以连接,但有时我的中央设备发现但无法连接。奇怪的