Background services: kill when you destroy activity

I created background servicea tab androidusing the method startService()inside Activity. Then I create the Threadon method onStart(). I read from the Android developer site that the service does not depend on activity, but when I destroy the Activityandroid system , it also kills service. I want the service to continue until I stop it myself.

I know this can be done with help AlarmManger, but it consumes battery. There is no need for a push notification, but the service should be running in the background. Any suggestions on how to solve this?

+4
source share
3 answers

 @Override
    public void onDestroy() {


           Log.e("serive destroyed", "service distroyed");
        super.onDestroy();
    }
0

AsyncTask , , Snicolas. . .

0

, , .

- , , . , Android . , , - , . .

0

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


All Articles