Background Service stop after power saver enable and disable

被刻印的时光 ゝ 提交于 2019-12-11 02:15:43

问题


I have an application in which I perform some task in background,

So the task will perform if my background service is running

Problem : When I enable and disable power saver, so it close everything and stop every background services which are running. After turning off power saver the service is not getting start till I open the application.

So how I can restart my background service when power saver off for lower version than Android.M

Facing issue in Android 6.0 and below.

Myservice.java

public class Myservice extends Service {

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return Service.START_STICKY;
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public boolean stopService(Intent name) {
        return true;
    }
}

I Start this service is my MainActivity.java

So I can get any kind of broadcast or notification of power saver

来源:https://stackoverflow.com/questions/46500119/background-service-stop-after-power-saver-enable-and-disable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!