Android Question GATT table clear

jemajuca

Member
Licensed User
Hello.
On my app, I need to scan BT to find my BTLE peripheral and connect with it.
No problems with that, but I also need to reconnect to the same device, and refresh GATT for discover new services on the same app session.
A method like disconnecting BT manually and reconnecting it again works well, but when I tried to do it programmatically, the results are not consistent or fails.
I'm using the Phone lib.

This is the piece of code:

B4X:
Sub ConectarBT

  BT.Disable
  Do While (BT.IsEnabled)
    'Power OFF BT
  Loop
  BT.Enable
  Do While Not (BT.IsEnabled)
    'Power ON BT
  Loop
 
  If  (currentStateText<>"UNSUPPORTED") Then
    manager.Scan(Null)
  Else
    ToastMessageShow("Bluetooth LE NOT supported" ,True) : PWROFFBT
  End If
 
End Sub

Any more reliable solution?
Thanks in avance.
 

jemajuca

Member
Licensed User
Hello Erel
Thank you for your help.
It's OK, that was only tor testing.
About using BluetoothAdmin instead, why it needs ACCESS_COARSE_LOCATION permission?
 
Upvote 0
Top