sendWakefulWork not always called with cwac-wakeful-1.1.0

后端 未结 1 1778
失恋的感觉
失恋的感觉 2021-01-21 12:38

I\'ve got a problem for a long time now and I discovered cwac-wakeful, which could solve all my problems. I thought... :\'( In short, for solving the problem, I\'ve implemented

相关标签:
1条回答
  • 2021-01-21 13:28

    In terms of the time gap, most likely, you are experiencing Doze mode on Android 6.0+ devices, or the equivalent offered by some manufacturers on older devices (e.g., SONY's STAMINA mode). Other than adding your app to the appropriate whitelist (e.g., for Doze, Settings > Apps > (gear icon) > Special access > Battery optimization), there is very little that you can do.

    You are welcome to switch to setExactAndAllowWhileIdle() on API Level 23+ devices, however:

    • You will not get control every minute (I think it is limited to every 9 minutes)

    • You will not have Internet access when you do get control (which presumably is required for whatever you are trying to do for real)

    • This will not help for manufacturer-specific pre-6.0 devices (since that method does not exist)

    Overall, designing your app to deal with Doze mode, and not assume that it will get control much in the background, is a more reliable approach.

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