Asked  7 Months ago    Answers:  2   Viewed   36 times

I want to close my application, so that it no longer runs in the background.

How to do that? Is this good practice on Android platform?

If I rely on the "back" button, it closes the app, but it stays in background. There is even application called "TaskKiller" just to kill those apps in the background.



Just to answer my own question now after so much time (since CommonsWare commented on the most popular answer telling we should NOT do this):

When I want to quit the app:

  1. I start my first activity (either splash screen, or whatever activity is currently at the bottom of the activity stack) with FLAG_ACTIVITY_CLEAR_TOP (which will quit all the other activities started after it, which means - all of them). Just make to have this activity in the activity stack (not finish it for some reason in advance).
  2. I call finish() on this activity

This is it, works quite well for me.

Tuesday, June 1, 2021
answered 7 Months ago

Grendel here is the absolute easiest two ways to close the Kotlin App the first way will open the app on PageTwo when it is reloaded not elegant but I included on the chance that someone has a Splash Screen


The second way is so simple and old you are going to scream It will close the Kotlin App and when reloaded the MainActivity is shown first


I tested this with Nexus 9 API 26 I do not have a Samsung Galaxy S2 but feel free to mail me one ha ha

Monday, August 16, 2021
answered 4 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :