Android Question Get bluetooth Current State using Reflector ?

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi All

Can someone post the code required to get the current state of the local Bluetooth please, I have been try all morning and it has eluded me :(

B4X:
Sub getState() As Int

   Dim r As Reflector, res As Int
   Dim BluetoothManager As Object
  
   r.Target = r.GetContext
  BluetoothManager = r.RunMethod2("getSystemService", "bluetooth", "java.lang.Integer")
  r.Target = BluetoothManager
   res = r.RunMethod("getState")

   mod_functions.writelog("svc_bt_state_changed(),getState, STATE = " & res)
  
   Return res

End Sub

Obviously the above code does not work...

Cheers

John.
 
Last edited:
Top