Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Killing android application on pause

I have an application which I would like to be fully disabled/closed when it is paused (IE. When the user presses the Home, End (call) and Back button I would like the application to be closed, instead of being saved in the history stack).

How do I do this....?

Thanks.

like image 395
Tom Avatar asked Jun 21 '09 21:06

Tom


People also ask

What is onResume method in android?

onResume() is called whenever you navigate back to the activity from a call or something else. You can override the onResume method similarly as onCreate() and perform the task.

When onDestroy is called in android?

onDestroy( ) is called before the activity is destroyed. The system invokes this callback either because: the activity is finishing (due to the user completely dismissing the activity or due to finish( ) being called on the activity), or.

What is onStart method in android?

onStart(): This method is called when an activity becomes visible to the user and is called after onCreate. onResume(): It is called just before the user starts interacting with the application. onPause(): It is called when the app is partially visible to the user on the mobile screen.


1 Answers

You know how you have an OnCreate() method in your activity which performs actions when you start. You need to add something like:

@Override

protected void onPause(){
finish();

        super.onPause();

}

in your activity to add actions before it starts

in this case the

finish(); 

command is what you want to execute before your activity pauses.

like image 183
blorgggg Avatar answered Sep 20 '22 09:09

blorgggg