Public Sub GetDeviceName As String
Try
Dim adapter As JavaObject
adapter = adapter.InitializeStatic("android.bluetooth.BluetoothAdapter").RunMethodJO("getDefaultAdapter", Null)
'Log("Name device: " & adapter.RunMethod("getName", Null))
Dim N As String
n = adapter.RunMethod("getName", Null)
' Log("Name device: " & n)
Return n
Catch
Log(LastException)
Msgbox("No se puedo obtener device name","Error")
End Try
End Sub
i try to get permissio, but , what permission and how?
Error occurred on line: 1457 (frmMain)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
at com.netsistemas.partes.frmmain.afterFirstLayout(frmmain.java:108)
at com.netsistemas.partes.frmmain.access$000(frmmain.java:20)
at com.netsistemas.partes.frmmain$WaitForLayout.run(frmmain.java:86)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for android.content.AttributionSource@58d729b0: getName
at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
at android.os.Parcel.createException(Parcel.java:2995)
at android.os.Parcel.readException(Parcel.java:2978)
at android.os.Parcel.readException(Parcel.java:2920)
at android.bluetooth.IBluetoothManager$Stub$Proxy.getName(IBluetoothManager.java:552)
at android.bluetooth.BluetoothAdapter.getName(BluetoothAdapter.java:1552)
... 19 more
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.bluetooth.BluetoothManagerService.checkPermissionForDataDelivery(BluetoothManagerService.java:3112)
at com.android.server.bluetooth.BluetoothManagerService.checkConnectPermissionForDataDelivery(BluetoothManagerService.java:3130)
at com.android.server.bluetooth.BluetoothManagerService.getName(BluetoothManagerService.java:1843)
at android.bluetooth.IBluetoothManager$Stub.onTransact(IBluetoothManager.java:256)
at android.os.Binder.execTransactInternal(Binder.java:1280)
You need to declare the permission with AddPermission(android.permission.BLUETOOTH_CONNECT) in the manifest editor and request it at runtime with rp.CheckAndRequest("android.permission.BLUETOOTH_CONNECT")