Stopping and starting a Service based on application state

后端 未结 8 1581
北海茫月
北海茫月 2021-01-05 16:45

I have a Service which tracks the location of the user. Currently, the Service boots when the application starts and stops when the application terminates. Unfortunately,

8条回答
  •  醉酒成梦
    2021-01-05 17:16

    You should override the onPause and onResume methods on your Activity. If you have multiple activities you may want to have a common base class for them and put the start/stop logic into the base class.

提交回复
热议问题