Android Question Change bluetooth device name

uniplan

Active Member
Licensed User
Longtime User
the code haven't error, but the name of device is the same, not changed.

What type of permission i must be added?

this is my code
B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim admin As BluetoothAdmin
    Dim serial1 As Serial
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private LabelTitolo As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
   
    If FirstTime Then
       
        admin.Initialize("admin")
        serial1.Initialize("serial1")
    End If
    Activity.LoadLayout("frmEmulaA775")
    Dim is_en As Boolean = admin.IsEnabled
   
    If is_en=True Then
        SetBluetoothName("TEST")
        Else
            ToastMessageShow("Attivare il bluetooth",True)
    End If
   
    
     ridimensiona
    
End Sub

Sub ridimensiona
    rsz.ridm_obj(LabelTitolo)
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

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
If the device was previously connected in the other device that the name is probably cached inside this device.

The name on this device will not change unless you remove it and scan again for devices on the phone...
 
Upvote 0

uniplan

Active Member
Licensed User
Longtime User
I think also that is my version of Android.
I tested my app on another phone (Android 4.4.2) and i correctly change my device name.
If i test my app on Samsung S6 (Android 7.0), i can't change device name.

It's possible this version problem?
 
Upvote 0
Top