Android Question [Solved]Sub activity_permissionresult was not found.

teddybear

Well-Known Member
Licensed User
I have 2 PCs, same IDE, B4A 12.2 JDK-14.0.1, Android SDK + Required Resources are same, the app example is BLE2.

A PC compiled APK, it works fine,
another PC compiled APK, it works first time, after app process exited, run it again it crashed.
In Debug mode, I got the log which release mode
B4X:
Logger connected to:  Xiaomi 22021211RC
--------- beginning of main
Copying updated assets files (9)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
Found: , FD:51:FC:CF:28:98, RSSI = -94, (MyMap) {-1=[B@ecd1665, 0=[B@1437f3a}
connecting
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
java.lang.Exception: Sub activity_permissionresult was not found.
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:227)
    at anywheresoftware.b4a.BA$2.run(BA.java:395)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:210)
    at android.os.Looper.loop(Looper.java:299)
    at android.app.ActivityThread.main(ActivityThread.java:8213)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)

In Debug mode
the program is blocked at wait for B4XPage_PermissionResult
B4X:
For Each per As String In Permissions
    rp.CheckAndRequest(per)
'=== Here is blocked ==='
    Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
'=======================
    If Result = False Then
        ToastMessageShow("No permission: " & Permission, True)
        Return
    End If
Next
 
Last edited:
Solution
Assuming that the template code in Main module is correct, it is possible that you have an old copy of RuntimePermissions library in the internal libraries folder. I suggest deleting all files in the internal libraries folder and reinstall B4A.

teddybear

Well-Known Member
Licensed User
Assuming that the template code in Main module is correct, it is possible that you have an old copy of RuntimePermissions library in the internal libraries folder. I suggest deleting all files in the internal libraries folder and reinstall B4A.
Thank you for the reply. the template code in Main module is correct because I don't modify the example. as you suggest, I have uninstalled b4a and reinstalled it and Android SDK + Required Resources on new folder.
The problem is same
Attached the error apk link, perhaps can find the issue out from it
 
Last edited:
Upvote 0

teddybear

Well-Known Member
Licensed User
This will not help.

I suggest deleting all files in the internal libraries folder and reinstall B4A.
Thanks again, I did that as you suggest, but issue is still existed.
if I put the code to default project instead of b4xpage, no problem
B4X:
Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
    Dim Permissions As List
    Dim phone As Phone
    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)
        ' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean) 'B4xPage project it will be crashed
        If Result = False Then
            ToastMessageShow("No permission: " & Permission, True)
            Return
        End If
    Next
End Sub
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Upload a small project.
The project has no problem. as I said, I have 2 PCs, one is normal and the other is problematic. I even copy all files of IDE from the normal one to the other.
 

Attachments

  • Project.zip
    14 KB · Views: 54
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Check your internal library-folder on the DEFECTIVE PC. Here you have a problem probably.
On defective PC:
delete all files from the INTERNAL library folder. Reinstall B4A

Something is wrong with PC2...
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Check your internal library-folder on the DEFECTIVE PC. Here you have a problem probably.
On defective PC:
delete all files from the INTERNAL library folder. Reinstall B4A

Something is wrong with PC2...
Thanks for your suggestion, I am sure I have done all of the things you mentioned, it doesn't seem like the RuntimePermissions library problem, because default project has no problem.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
it doesn't seem like the RuntimePermissions library problem, because default project has no problem
a old runtimepermissionlibrary had issues with B4XPages. The one installed with B4A12+ does not have this issue.

It looks like you are using an old one somehow on PC2.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
You can do a test an check the library-version in the librarymanager tab. On both PCs.
Which Version of Runtimepermission is running on PC1? Which Version on PC2?
Both should be 1.12
Both are 1.12
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Thank you a lot @Erel and @DonManfred

The problem is solved, it's my fault, I made a low-level mistake, there is an old Runtimepermission library in additional libraries folder. I deleted it and the problem is solved

Thank you all so much for your patience again.

 
Upvote 0
Top