Close Android App

How can I close the application programmatically?

I used

finish(); 

or

 android.os.Process.killProcess(android.os.Process.myPid()); 

or

 System.exit(0); 

or

 moveTaskToBack(true); 

but it closed the current current activity, but I need to close the entire application

I need to close the application to get some memory, and then restart the application again.

Or

Is there a way to clear all application memory?

+8
android
source share
1 answer

Using these lines in your activity: -

 this.finish(); Process.killProcess( Process.myPid() ); 

it will kill your entire application (provided that it works in one process), it will also free up any associated memory.

A WARNING. On some phones, this may cause the bluetooth connectors to freeze if you use them.

+10
source share

All Articles