Stop a service after MainActivity is closed (EDITED)

后端 未结 3 921
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-26 07:21

I think im not clear at all, i do want the service to persist even if the main activity is destroyed via user action or android system does it, it does it well, but when the app

3条回答
  •  粉色の甜心
    2021-01-26 07:51

    Maybe all you need to do is check to see if it's null before attempting to stop it:

    private void stopBg(){
         if(BgServiceIntent != null)
             stopService(BgServiceIntent);
    }
    

提交回复
热议问题