Home > Mobile >  Android development, judge the state of the bluetooth connection
Android development, judge the state of the bluetooth connection

Time:09-17

Phone HC - 06 bluetooth module is connected with the arduino is successful, but if arduino power, bluetooth connection is disconnected at this time, how to determine the status??
In online search method is to use the radio, I write the code below,
This is a welcome page, if the first enter the app, just skip to bluetooth connection page, if not the first time, but the bluetooth connection is broken or bluetooth closed, jump to the same bluetooth connection page, bluetooth closed state can judge, is disconnected state cannot judge,
Please tell the great god!

CodePudding user response:


 device. ConnectGatt (BluetoothLeService. This false, mGattCallback); 

Registered BluetoothGattCallback interface, through onConnectionStateChange newState because fields determine whether disconnect

 
If (newState because==BluetoothProfile. STATE_DISCONNECTED)

CodePudding user response:

The
reference 1/f, 113 dancers keyboard response:
 device. The connectGatt (BluetoothLeService. This false, mGattCallback); 

Registered BluetoothGattCallback interface, through onConnectionStateChange newState because fields determine whether disconnect

 
If (newState because==BluetoothProfile. STATE_DISCONNECTED)

Ok, thank you, I have a try??????

CodePudding user response:

refer to the second floor MrSmile1234 response:
Quote: reference 1/f, 113 dancers keyboard response:

 device. ConnectGatt (BluetoothLeService. This false, mGattCallback); 

Registered BluetoothGattCallback interface, through onConnectionStateChange newState because fields determine whether disconnect

 
If (newState because==BluetoothProfile. STATE_DISCONNECTED)

Ok, thank you, I have a try??

Hello, you write on the device. The connectGatt (BluetoothLeService. This false, mGattCallback);
I didn't find there are BluetoothLeService
Only BluetoothLeAdvertiser
BluetoothLeScanner
  • Related