Android deep sleep and wake locks

前端 未结 1 645
忘掉有多难
忘掉有多难 2021-01-16 05:54

I have created an android app which runs fine in all phones. But in my Alcatel phone it doesn\'t as the phone goes to a deep sleep mode and the data network fails so the app

1条回答
  •  被撕碎了的回忆
    2021-01-16 06:21

    The lock you have in your service never runs - cause your service is never run

    Well - you have to use a WakefulIntentService - make your MyDataService extend WakefulIntentService and in your receiver call WakefulIntentService.doWakefulWork(context, MyDataService.class)

    Or implement a static lock shared by both your service and receiver - which would be tricky.

    If using wifi you should also need to use a WifiLock - inside your wakeful intent service - can get tricky

    0 讨论(0)
提交回复
热议问题