Disable the application from the music library

Is there a way to disconnect my application from running in the background? I do not want my application to run in the background, I need to completely close it when the user has executed

+3
source share
1 answer

Call finish()all your actions correctly when you close them. If you have started any actions that are awaiting a result, be sure to run setResult()these actions until completion.

If you have threads with loops, keep a global variable indicating whether your application is running. Set this variable to true when your activity resumes (calls onResume()) and sets the variable false when your activity pauses ( onPause()). Then you just need the loops of your threads to check this global variable before the loop to make sure they stop finesse after your activity ends.

In addition, your actions should automatically try to complete when the user presses the "Back" button in the last action on the stack, ending your application.

+1
source

Source: https://habr.com/ru/post/1755393/


All Articles