Is there any way to disa开发者_StackOverflowble 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
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.
精彩评论