Android Question Can you detect and change the bluetooth device name with B4A code?

DickD

Active Member
Licensed User
Can you detect and change the bluetooth device name with B4A code? I don't see anything in the BT docs on this.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub GetBluetoothName As String
   Dim jo As JavaObject
   Return jo.InitializeStatic("android.bluetooth.BluetoothAdapter").RunMethodJO("getDefaultAdapter", Null) _
     .RunMethod("getName", Null)
End Sub

Sub SetBluetoothName (Name As String)
   Dim jo As JavaObject
   Return jo.InitializeStatic("android.bluetooth.BluetoothAdapter").RunMethodJO("getDefaultAdapter", Null) _
     .RunMethod("setName", Array(Name))
End Sub

Make sure that BluetoothAdmin.IsEnabled is True before calling these methods.
 
Upvote 0
Top