Android Question What happens when I exit my app?

pjetson

Member
Licensed User
Longtime User
As I understand it, when I used the back button to “exit” an app, Android effectively just “pauses” the app, keeping it in memory ready to run if the user “starts” the app again. And Android may “unload” my "paused" app completely if it needs more memory at any time. My apologies if I do not know the correct terms for these operations.

When a B4A app is in this paused state, what happens to a service that the app has started? Is the service also paused, or does/can it continue to run in the background?

And what about timers? Are they paused as well? And if so, when the app starts again, does the timer continue from where it was (ie part way through the timer interval), or does the timer event fire if the time interval has expired while the app was paused?

Also, when an app is restarted from the paused state, is it restarted in exactly the same way as if the app had never been running?

On a kind of related note, why is it considered “bad” for an app to have an “exit” button? Might it not be easier for someone to press a button in the app rather than the official back button when they want to get back to the Android desktop?
 
Last edited:

Fusseldieb

Active Member
Licensed User
Longtime User
what happens to a service that the app has started?
The service keeps running and will not be killed, if it has a Notification showing in the Notification Bar.

And what about timers? Are they paused as well?
They will be paused. If you reopen your app they will most likely continue.

Also, when an app is restarted from the paused state, is it restarted in exactly the same way as if the app had never been running?
No, it tries to continue form where it has paused.

On a kind of related note, why is it considered “bad” for an app to have an “exit” button? Might it not be easier for someone to press a button in the app rather than the official back button when they want to get back to the Android desktop?
They continue running in the background so that they can start faster when you need it. But if you want to literally CLOSE the app, you can kill it by using:
B4X:
ExitApplication
With this code the app will close imediately.

Hope I helped ;)
 
Upvote 0

pjetson

Member
Licensed User
Longtime User
Hi, Fusseldieb - nice avatar :)

Regarding the exit button, I don't want to kill the app. I'm happy for my exit button to do exactly the same thing as the back button. I just wanted to know why some people seem so adamant that an app should not have an exit button.
 
Upvote 0
Top