How to handle Screen dim for android widget
Can anybody help please how could be handle the Screen dim so that widget will not update at that time. Its keeps the Screen on all the time.
I could handle the开发者_Go百科 Screen OFF and Screen On Intents and check it in BroadcastReceiver not to update the widget while screen is OFF. But there is no intent for Screen dim.
Use the PowerManager
class to check wither the screen is on/off at points where you need to.
PowerManager pw = (PowerManager)this.getSystemService(Context.POWER_SERVICE);
if(!pw.isScreenOn()) //check wither the scr is off/on
{
wl = pw.newWakeLock(PowerManager.ON_AFTER_RELEASE, "WakeUpBuddy");
wl.acquire();
}
精彩评论