Forced maintenance and service intent kill when the application is destroyed

In my application, I try to load images, even though the user turned it off and logged out using the recent application manager by scrolling. Why I want this behavior, it has only one reason:

Since I want the User to stop downloading from my button specified in the action

So, for this, I made the asynchronous task in the first place, it worked perfectly, even if the activity is destroyed. But when I destroy / kill my application using the last application, the application is killed, and therefore the service

Then I moved my asynchronous task to the Service, which was sticky, I thought that it should not be destroyed when the user closes the application from the latest application lists, but the Service stops. although it starts over several times, but for some reason I just want it to not stop and load like in google play store. Whatever you do, you cannot stop downloading the application until you use the stop button in the Google Play Store application.

Then I read about IntentService, the intent service I read,

You can start an intentional service and forget about it, since it stops after the task is completed.

, -, , , swiping,

. , , . .

Top , , , gps , . app google play store , , , , , , , , , .

, ? , google play.

, . .

+4
3

ForegroundService. Android , :

- , , , , , , ​​. , "", , , ​​ .

0

return return START_STICKY onStartCommand

0

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


All Articles