appwidgetprovider

Screen on/off broadcast listener for a widget on Android Oreo

拟墨画扇 提交于 2019-11-28 18:52:29
I have a clock widget Android app which I am now trying to update to API 26 requirements. Up to now I used a background service which registered upon start in its onCreate method a BroadcastReceiver to receive system broadcasts, such as android.intent.action.SCREEN_ON, android.intent.action.SCREEN_OFF, android.intent.action.TIME_SET, android.intent.action.TIMEZONE_CHANGED . This service was then pausing the clock while screen is off and waking it up when screen is back on to save the battery. In Oreo a service of this kind does not seem to be an option, because it would have to run in the

Screen on/off broadcast listener for a widget on Android Oreo

走远了吗. 提交于 2019-11-27 11:54:22
问题 I have a clock widget Android app which I am now trying to update to API 26 requirements. Up to now I used a background service which registered upon start in its onCreate method a BroadcastReceiver to receive system broadcasts, such as android.intent.action.SCREEN_ON, android.intent.action.SCREEN_OFF, android.intent.action.TIME_SET, android.intent.action.TIMEZONE_CHANGED . This service was then pausing the clock while screen is off and waking it up when screen is back on to save the battery.