Thanks for the quick response Peter. I'll upload new version today and report any issues. The fix works fine on my test device.
Cheers.
Greetings once again, Peter.
I obtained a Galaxy Note 10 running Android 12 and tried the suggested fix that you provided earlier. The program crashed when it tried to install. I recorded the following logs and screenshots:
My Manifest:
Here is the error log:
Logger connected to: samsung SM-N970U
--------- beginning of main
Copying updated assets files (120)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 26 (ConnectPlayer)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
at com.turbosoftsolutions.numberspy.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1087)
at com.turbosoftsolutions.numberspy.b4xpagesmanager._showpage(b4xpagesmanager.java:444)
at com.turbosoftsolutions.numberspy.b4xpagesmanager._addpage(b4xpagesmanager.java:264)
at com.turbosoftsolutions.numberspy.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:278)
at com.turbosoftsolutions.numberspy.b4xpagesmanager._initialize(b4xpagesmanager.java:170)
at com.turbosoftsolutions.numberspy.main._activity_create(main.java:421)
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:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at com.turbosoftsolutions.numberspy.main.afterFirstLayout(main.java:105)
at com.turbosoftsolutions.numberspy.main.access$000(main.java:17)
at com.turbosoftsolutions.numberspy.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8663)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
... 25 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
... 26 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
at com.turbosoftsolutions.numberspy.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1087)
at com.turbosoftsolutions.numberspy.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:281)
at com.turbosoftsolutions.numberspy.b4xpages._addpageandcreate(b4xpages.java:60)
at com.turbosoftsolutions.numberspy.b4xmainpage._b4xpage_created(b4xmainpage.java:308)
... 28 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
... 34 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
... 35 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at com.turbosoftsolutions.numberspy.connectplayer._initialize(connectplayer.java:78)
at com.turbosoftsolutions.numberspy.b4xfindnumberpage$ResumableSub_B4XPage_Created.resume(b4xfindnumberpage.java:756)
at com.turbosoftsolutions.numberspy.b4xfindnumberpage._b4xpage_created(b4xfindnumberpage.java:587)
... 37 more
Caused by: java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for AttributionSource { uid = 10349, packageName = com.turbosoftsolutions.numberspy, attributionTag = null, token = android.os.BinderProxy@34d03db, next = null }: getName
at android.os.Parcel.createExceptionOrNull(Parcel.java:2438)
at android.os.Parcel.createException(Parcel.java:2422)
at android.os.Parcel.readException(Parcel.java:2405)
at android.os.Parcel.readException(Parcel.java:2347)
at android.bluetooth.IBluetoothManager$Stub$Proxy.getName(IBluetoothManager.java:1194)
at android.bluetooth.BluetoothAdapter.getName(BluetoothAdapter.java:2345)
... 42 more
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.BluetoothManagerService.checkPermissionForDataDelivery(BluetoothManagerService.java:5032)
at com.android.server.BluetoothManagerService.checkConnectPermissionForDataDelivery(BluetoothManagerService.java:5050)
at com.android.server.BluetoothManagerService.getName(BluetoothManagerService.java:2835)
at android.bluetooth.IBluetoothManager$Stub.onTransact(IBluetoothManager.java:542)
at android.os.Binder.execTransactInternal(Binder.java:1215)
Message longer than Log limit (4000). Message was truncated.
** Activity (main) Resume **
Here is the line of code in Connect Class that causes the error:
#If B4A
Dim JO As JavaObject
MyDeviceName = JO.InitializeStatic("android.bluetooth.BluetoothAdapter").RunMethodJO("getDefaultAdapter", Null).RunMethod("getName", Null) 'Remember to add Manifest permission
#Else If B4i
Dim Name As NativeObject
MyDeviceName = Name.Initialize("UIDevice").RunMethod("currentDevice", Null).GetField("name").AsString
#Else If B4J
MyDeviceName = GetEnvironmentVariable("COMPUTERNAME", "")
#End If
And finally, the code snippet in my calling program:
Dim Phone As Phone
Dim RP As RuntimePermissions
Dim Permissions As List
If Phone.SdkVersion >= 31 Then
Permissions = Array("android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_CONNECT", RP.PERMISSION_ACCESS_FINE_LOCATION)
Else
Permissions = Array(RP.PERMISSION_ACCESS_FINE_LOCATION)
End If
For Each Per As String In Permissions
RP.CheckAndRequest(Per)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow("Permission must be granted", True)
' Activity.Finish
B4XPages.ClosePage(Me)
Return
Else
Log($"${Per} Permission granted"$)
End If
Next
I also include the Permissions:
Since my application does not require the "devicename", I stripped that code from the Connect Class and the program installs and runs normally. I modified the B4I and B4J Connect Class code in a similar way in order for the devices to communicate.
Sorry for the lengthy post as I know this thread is dated. I included all this for anyone still following as well as for you information. Thanks again for the help.
Cheers!