How to exit the Android application?

I just read that you can exit the Android application just by calling:

finish();

However, it is not! When I do this, I get the following errors:

PackageInstallationReciever Remove /data/local/tmp/com._____.apk Fail!
AndroidRuntime Uncaught handler: thread main exiting due to uncaught exception
AndroidRuntime java.lang.NullPointerException
AndroidRuntime     at android.....
dalvikvm Unable to open stack trace file '/data/anr/traces.txt': Permission denied

So what is the right way to get the application to exit? For the record, I call it from a menu item, but that doesn't seem to matter!

+3
source share
2 answers

You might want to watch Exit the application - is that flooded? in this section.

+5
source

What are you trying to accomplish with exiting in the app? If you want the application to not maintain state after the user exits, you can add this flag to the main activity in the manifest file:

android:clearTaskOnLaunch=true

.

+1

Source: https://habr.com/ru/post/1783897/


All Articles