Android Question how to handle Activity_KeyPress for ExitApplication

SMOOTSARA

Active Member
Licensed User
Hi guys 🌹

how to handle Activity_KeyPress for ExitApplication?

I go from the "main page" to the "second page" and from there to the "third page"

Click the back button on the "third page" and then return to the ""second page" and click again and return "main page"

Now if I am on the "main page" if click again I have to exit the program


B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
    ExitApplication !!!!!!!!
    Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End Sub
 

SMOOTSARA

Active Member
Licensed User
You don't need to do anything special. If the user clicks on the back key when there are no pages in the stack then the app moves to the background. This is the expected behavior.

I'm going to close the program completely
I do not want the app to be open in the background
 
Upvote 0

SMOOTSARA

Active Member
Licensed User
This is a mistake in 99% of the cases. You should let the OS handle the process life cycle. No need to worry about it.

If you want to make your app less reliable then handle the B4XPage_CloseRequest and call ExitApplication there.


" If you want to make your app less reliable then handle the B4XPage_CloseRequest and call ExitApplication there."
If possible for you🌹
Please guide me with a few lines of code 🙏
 
Upvote 0
Top