views:

52

answers:

1

Is there any way to disable my application from running on the background? I don't want my app to run in the background, i need to completely close it when the user a done

+1  A: 

Properly call finish() on all your activities when you close them. If you started any activities expecting a result value, be sure to call setResult() in those activities before finishing.

If you have any threads running loops, keep a global variable indicating if your app is running. Set this variable to true when your activity resumes (invokes onResume()), and set the variable to false when your activity pauses (onPause()). Then just have your threads' loops check this global variable before looping to make sure they terminate gracefully once your activity finishes.

Other than that, your activities should automatically try to finish when the user presses the back button on the last activity in the stack, terminating your application.

Andy Zhang
thanks a lot i'll give that a try
aryaxt