0

In an app written with jetpack compose, I finish the app with the following instructions:

val activity = (LocalContext.current as? Activity)
activity?.finish()
exitProcess(0)

In the Android Studio emulator, the app closes but when you click on the square button, the image of the app appears. If I select it, it starts again.

How to close the app so that it disappears completely?

  • You would need to clear the top of the task, and do a bit more to exclude it from recents... probably start a new "this activity is not part of the recent apps" while clearing the task and clearing top (`CLEAR_TASK | CLEAR_TOP` intent flags) and a bit of this https://stackoverflow.com/questions/13385289/remove-app-from-recent-apps-programmatically – Shark Dec 23 '22 at 16:23

1 Answers1

1

You can use this to close the application:

finishAndRemoveTask();
Ravi Mishra
  • 167
  • 1
  • 7