user3810288
user3810288

Reputation: 7

What is the correct way to terminate an app Android from the code?

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?

Upvotes: 0

Views: 1470

Answers (1)

Ravi Mishra
Ravi Mishra

Reputation: 167

You can use this to close the application:

finishAndRemoveTask();

Upvotes: 1

Related Questions