Android Question Capture back key in B4XPages

beltrao73

Member
Licensed User
Longtime User
Hi,

I would like to capture back key do other things, rather than closing the app

I tried this code:

B4X:
Sub B4XPage_CloseRequest As ResumableSub
   Return False
End Sub


But got this error:

Error occurred on line: 504 (B4XPagesManager)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug(Common.java:1050)
at tecsoft.ArgosGerente.b4xpagesmanager$ResumableSub_HandleCloseRequest.resume(b4xpagesmanager.java:814)
at tecsoft.ArgosGerente.b4xpagesmanager._handlecloserequest(b4xpagesmanager.java:784)
at tecsoft.ArgosGerente.b4xpagesmanager._activity_keypress(b4xpagesmanager.java:542)
at tecsoft.ArgosGerente.b4xpagesdelegator._activity_keypress(b4xpagesdelegator.java:66)
at tecsoft.ArgosGerente.main._activity_keypress(main.java:435)
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:144)
at tecsoft.ArgosGerente.main$HandleKeyDelayed.runDirectly(main.java:231)
at tecsoft.ArgosGerente.main$HandleKeyDelayed.run(main.java:228)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:7582)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.lang.RuntimeException: java.lang.Exception: Sub B4XPage_CloseRequest was not found.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
at anywheresoftware.b4a.debug.Debug.CallSubNew(Debug.java:282)
... 22 more
Caused by: java.lang.Exception: Sub B4XPage_CloseRequest was not found.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:326)

______________
 

Brian Dean

Well-Known Member
Licensed User
Longtime User
B4X:
Sub B4XPage_CloseRequest As ResumableSub
   Return False
End Sub
I don't think that there is anything wrong with this code; I have used it myself. The error is ocurring in B4XPagesManager so it is possible that it is being caused by something else, like an uninitialised object. Maybe someone else can read more from the log message.
 
Upvote 0
Top