How can i close my 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 running activity, but i need to close the whole application??
I need to close app to retrieve some memory and then restart application again.
Or
does there is a way to clear all memory of the application?
Using these lines in your activity:-
this.finish();
Process.killProcess( Process.myPid() );
will kill your whole application (assuming its running in a single process) it will also free any associated memory.
WARNING: On some phones doing this may leave bluetooth sockets dangling if you are using them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With