Android service stops working when phone locked

后端 未结 3 809
轻奢々
轻奢々 2021-01-12 08:06

I have an application which starts a service. The service has a timer and pops a notification every 30 seconds. I notice the following behavior:

  • if the screen
3条回答
  •  爱一瞬间的悲伤
    2021-01-12 08:19

    You don't. That would be the perfect way to quickly drain the phone's battery. If the phone is sleeping, let it sleep, unless you have a GOOD reason not to (in which case you use the AlarmManager for a one-time wake-up call in the future).

    I don't know what you're trying to achieve, but you need to use a completely different approach. A network tickle would be a good idea, for example, assuming you can live with your app being 2.2+ only.

提交回复
热议问题