Reputation: 91195
when i click a button my app should be terminated. It must not to run at the background. that is when holding the home key, My App should not be alive. For Example, i have to redirect my app to the browser. then My App goes to as a background Task. I want to terminate before the redirection to browser. How is it Possible? Any Idea? Better I would need a Explanation on that. that helps to understand How it works to EveryBody.
Thanks in Advance.
Upvotes: 4
Views: 7681
Reputation: 786
What i did is launch the activities with startActivityForResult(), and then, when i want to finish the application, set a result and finish(). Later, i got that result with:
public void onActivityResult(int requestCode, int resultCode, Intent data){...}
And if i got the expected result, finish that activity setting a new result for the previous one.
That works for me, but it's easy because i only have two previous activities in my case...
Upvotes: 0
Reputation: 5526
Like the answer above already said:
finish();
return;
Good luck
Tom
Upvotes: -3
Reputation: 7052
http://developer.android.com/guide/topics/fundamentals.html#clearstack
The finishOnTaskLaunch attribute
This attribute is like clearTaskOnLaunch, but it operates on a single activity, not an entire task. And it can cause any activity to go away, including the root activity. When it's set to "true", the activity remains part of the task only for the current session. If the user leaves and then returns to the task, it no longer is present.
.. or something like this. I'm new to android, and had just past this part of the docs, and I thought it might help.
EDIT: maybe call finish()
in onPause()
?
Upvotes: 4