[英]Screen on and then off too fast when using WakeLock (not remaining on for a few second)
I'm facing a problem using Wake lock through PowerManager API. 我在通过PowerManager API使用唤醒锁时遇到问题。 Currently, i have a service and a broadcast receiver.
目前,我有一个服务和一个广播接收器。
My service has 2 main roles : 我的服务有2个主要角色:
I'm using Mark murphy's cwac-wakeful module to achieve that and it works just fine. 我正在使用Mark murphy的cwac-wakeful模块来实现这一点,并且效果很好。
The problem is : the screen turns on and off too fast for the user to see it. 问题是:屏幕打开和关闭的速度太快,用户看不到它。
Here is what's happening when the alarm intent is launched (for the second role/case) : 这是启动警报意图时发生的情况(针对第二个角色/情况):
As you have probably understood. 如您所了解。 The problem is, the lock is released too fast after the service finishes so i can just see the screen turning on and off in less that one second.
问题是,服务完成后,锁释放得太快,因此我只能在不到一秒钟的时间内看到屏幕打开和关闭的情况。 I thought that using the ON_AFTER_RELEASE (the doc says : "If this flag is set, the user activity timer will be reset when the WakeLock is released, causing the illumination to remain on a bit longer. This can be used to reduce flicker if you are cycling between wake lock conditions. ") would have solved my problem, but no.
我以为使用ON_AFTER_RELEASE(文档说:“如果设置了此标志,则释放WakeLock时将重置用户活动计时器,从而使照明保持更长的时间。如果您需要在唤醒锁定条件之间循环。“)可以解决我的问题,但没有。
When googling, i found a solution that consists in : 谷歌搜索时,我发现了一个解决方案,其中包括:
Then my question is how can i maintain the screen on for a few seconds (say 10/15 sec) like when i receive an sms, what is the best solution to achieve that ? 然后我的问题是,如何像接收短信时那样将屏幕保持开启状态几秒钟(例如10/15秒),实现此目的的最佳解决方案是什么?
Any help would be greatly appreciated, and thanks in advance ! 任何帮助将不胜感激,并预先感谢!
I had a similar situation in that my app was shutting down immediately after I released a WakeLock. 我遇到类似的情况,因为我释放WakeLock后立即关闭了应用程序。 I think I applied the same logic to it that you did, but I used a FULL_WAKE_LOCK with the other options PowerManager.ACQUIRE_CAUSES_WAKEUP |
我想我对它应用了与您相同的逻辑,但是我将FULL_WAKE_LOCK与其他选项PowerManager.ACQUIRE_CAUSES_WAKEUP |一起使用。 PowerManager.ON_AFTER_RELEASE.
PowerManager.ON_AFTER_RELEASE。 This seemed to do the trick for me in my "GameTime" timer application.
在我的“ GameTime”计时器应用程序中,这似乎对我有用。 I know this was posted a while a ago, but maybe it would provide some help to someone!
我知道这是前一段时间发布的,但也许会对某人提供一些帮助!
There is a line in API documentation that states: "In addition, you can add two more flags, which affect behavior of the screen only. These flags have no effect when combined with a PARTIAL_WAKE_LOCK." API文档中有一行指出:“此外,您还可以添加两个标志,这些标志仅影响屏幕的行为。与PARTIAL_WAKE_LOCK结合使用时,这些标志无效。” I wonder if SCREEN_DIM_WAKE_LOCK counts as a PARTIAL WAKE LOCK?
我想知道SCREEN_DIM_WAKE_LOCK是否算作部分唤醒? (undocumented 'feature')
(未记录的“功能”)
API located here: http://developer.android.com/reference/android/os/PowerManager.html API位于: http : //developer.android.com/reference/android/os/PowerManager.html
I think you provide the answer: 我认为您提供了答案:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.