Android Question [FIXED] [B4X] B4XPages - problem with Permissions (not CloseRequest as thought)

agraham

Expert
Licensed User
Longtime User
I'm playing with CloseRequest which I have placed in B4XMainPage on the ThreePagesExample project. This is an Android 10 device.
B4X:
'Return True to close, False to cancel
Private Sub B4XPage_CloseRequest As ResumableSub
    Dim sf As Object = xui.Msgbox2Async("Close?", "Title", "Yes", "Cancel", "No", Null)
    Wait For (sf) Msgbox_Result (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Return True
    End If
    Return False
End Sub

In order for this to keep working I seem to have to uninstall the app before re-installing it again. If I don't the app immediately crashes with a "Sub activity_permissionresult was not found" error when it is reinstalled, and when trying to run it subsequently. Uninstalling before reinstalling it again lets it then behave as expected.
 

agraham

Expert
Licensed User
Longtime User
Yes, it happens in release mode. In fact I almost never use Debug mode. It also happens on my Android 8 Samsung A3 as well as my Android 10 Xaiomi Mi Max 3.

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.Exception: Sub activity_permissionresult was not found.
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:219)
    at anywheresoftware.b4a.BA$2.run(BA.java:387)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:224)
    at android.app.ActivityThread.main(ActivityThread.java:7520)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
It seems to be an interaction between asking for PERMISSION_WRITE_EXTERNAL_STORAGE and trapping CloseRequest. If I comment out either the problem doesn't occur. Perhaps I've got the permission request in the wrong place.
 

Attachments

  • B4AProject.zip
    14.5 KB · Views: 271
Upvote 0
Top