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.
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.
You seem to need to allow the PERMISSION_WRITE_EXTERNAL_STORAGE for the problem to occur on the next re-installation. If you don't it behaves as expected.
Sorry. I was wrong about the involvement of CloseRequest. I was probably guilty of changing too many things each time I tested. The problem is solely related to accepting the PERMISSION_WRITE_EXTERNAL_STORAGE permission.