Android Question Back key and home key on the device

Status
Not open for further replies.

ciginfo

Well-Known Member
Licensed User
What do exactly the Back key and the Home key on the device in B4A
Close app ? Close activity ? I don't understand exactly when i read thé guides
Thank you
 

Erel

Administrator
Staff member
Licensed User
Tip: switch to B4XPages and everything will be simpler.

In non-B4XPages the back button destroys the current activity and the home button pauses the activity and shows the home screen.
In B4XPages the back button hides the current page. Pages are never paused or destroyed. The home button moves the app to the background.
 

beltrao73

Member
Licensed User
I tried this code to prevent back key from closing app:

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

Active Member
Licensed User
B4X:
Sub B4XPage_CloseRequest As ResumableSub
    Return False
End Sub
This does work - it prevents the app closing. This statement is not itself causing your error - the error is happening because you have a coding problem somewhere else.
 
Status
Not open for further replies.
Top