Reputation: 869
Application is having 2 activities. I am using following code in each activity to close the application totally and free all resources when home button is pressed. But when i restart the app, it starts from the activity it left earlier. How to achieve the objective.
@Override
public void onStop(){
super.onStop();
super.onDestroy();
}
Upvotes: 0
Views: 692
Reputation: 27539
Call finish()
instead of this and you must exit the app from the main activity itself.
If you pressing Home button on any activity , it will start the same Activity next time.
Or add more detail in your question for better solution.
Upvotes: 0
Reputation: 8612
super.onDestroy()
in onStop
method!finish()
for activity stoping.System.exit()
Upvotes: 1
Reputation: 2795
Finish all the activity first and before finishing last activity just add the below line
android.os.Process.killProcess(android.os.Process.myPid());
which will kill the process which is started for that application.
Upvotes: 0
Reputation: 15052
You cannot close your application at your need. You can call finish()
in every Activity
when you navigate away from it. But then again, there is no guarantee that the OS will free up the resources immediately and close your Activity
.
Never try to implement something like exiting your application. Read this for a good discussion on it.
Upvotes: 1