Service pauses on screen lock

前端 未结 3 612
说谎
说谎 2021-01-26 19:02

For testing purposes i have made a service that beeps every 1 minute. (No client-server interface yet). It beeps okay when the screen in on, but when it goes to sleep the beepin

3条回答
  •  天命终不由人
    2021-01-26 19:19

    You want to acquire a partial wake lock (leaving the CPU running whenever sleep is entered on the device) as suggested by your code.

    The issue is your presumably overriden on start releases the wake lock. You want to release your wakeLock in onDestroy .. once your service is finished running.

提交回复
热议问题