开发者

How to handle Screen dim for android widget

开发者 https://www.devze.com 2023-04-06 12:26 出处:网络
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.

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();
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号