Wake locks android service recurring

前端 未结 3 1829
春和景丽
春和景丽 2020-12-05 03:27

I have this application that needs to run a service (background) that beeps periodically. The phone needs to beep the entire day for 5 seconds every one minute (used a hand

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 04:03

    I think you'd be better off using android.app.AlarmManager to schedule a wakeup alarm. Be careful though - you don't want to do any long-running work in your onReceive() method as that's normally called on the main thread, and will hang your activity. You'll still need to acquire the wakelock for the duration of your task to prevent the phone sleeping part-way through.

提交回复
热议问题