How to programmatically complete an application in Android?

when I click the button, my application should be terminated. He should not run in the background. that is, holding the home key, My App should not be alive. For example, I have to redirect my application to a browser. then my application goes into the background job. I want to exit before being redirected to the browser. How is this possible? Any ideas? Better I need an explanation. which helps to understand how it works with EveryBody.

Thanks at Advance.

+4
source share
3 answers

http://developer.android.com/guide/topics/fundamentals.html#clearstack

FinishOnTaskLaunch attribute
This attribute is similar to clearTaskOnLaunch, but it only works with one action, not a solid task. And this can lead to the fact that any activity disappears, including root activity. When set to true, the action remains part of the task only for the current session. If the user leaves and then returns to the task, he is no longer present.

.. or something like that. I am new to android, and just went through this part of the docs, and I thought it might help.

EDIT: maybe the call to finish() in onPause() ?

+4
source

What I did was start the action using startActivityForResult (), and then when I want to end the application, set the result and complete (). Later I got this result:

public void onActivityResult (int requestCode, int resultCode, Intent data) {...}

And if I get the expected result, complete this step by setting a new result for the previous one.

This works for me, but it’s easy because I only have two previous actions in my case ...

0
source

As mentioned above:

 finish(); return; 

Good luck
Tom

-3
source

All Articles