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


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.
'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.


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.

*** 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(
    at anywheresoftware.b4a.BA$
    at android.os.Handler.handleCallback(
    at android.os.Handler.dispatchMessage(
    at android.os.Looper.loop(
    at java.lang.reflect.Method.invoke(Native Method)
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.


    14.5 KB · Views: 293
Upvote 0