I have a bluetooth headset which is paired with my Nexus 5X (running Android 7.1) and I would like to connect to a GATT Server of the headset. I tried it with the following
In fact,I solve this problem by Execution the method mBluetoothGatt.discoverServices() several times(10 or more),
int i = 10;
while (i > 0)
{
if (!mIsBLE_Finded) //如果服务发现失败,继续执行discoverServices方法
{
i--;
mBluetoothGatt.discoverServices();
System.out.println("BLEService-->" + "尝试次数:" + i);
}
else //在10次的尝试中,存在某次服务发现成功了
{
i = -1;
}
}