在使用RTC报警Android上使手机的睡眠 [英] Allowing the phone to sleep while using RTC alarm on Android
问题描述
我已经看到我使用RTC(非唤醒)手机会可靠地发送了正确的重复间隔PendingIntents使用报警管理器Android的一些奇怪的问题,尽管事实。
我测试的细节
- 在设备不充电,只是坐在我的床头,而我睡
- 在我的服务醒了它的重复间隔时间(30分钟,一个极端的,我知道)EVERY TIME
- 在服务记录了在一个文件中的活动,所以我可以在早上 阅读
现在从我的理解手机的应该的是睡觉,除非我醒了起来,我报警不应该被发送,直到手机被唤醒。
- 为什么我的业务执行?
- 如果另一个服务行为不正常,并使用报警_WAKEUP变体将我的服务醒过?
- 在我能避免被唤醒另一个服务,然后从打开屏幕上? 用户只要醒着
为什么我的业务执行?
presumably别的东西是具有设备醒着的时刻。
如果另一个服务行为不正常,并使用报警_WAKEUP变体将我的服务醒过?
是的,尽管行为不端是在旁观者的眼睛。
我能否避免被唤醒另一个服务,并转动屏幕上的用户只要醒了吗?
不是直接通过 AlarmManager
。你可以看的 ACTION_SCREEN_OFF
和 ACTION_USER_ preSENT
广播,也许禁用那些与你的报警。
I've been seeing some strange issues using the Alarm manager in Android, despite the fact that I'm using RTC (non Wakeup) the phone will reliably send the PendingIntents on the correct repeating intervals.
Details of my test
- Device is not charging, just sitting on my nightstand while I slept
- My service woke up on its repeat interval (30 minutes, an extreme I know) EVERY TIME
- The service logged its activity in a file so I could read it in the morning
Now from my understanding the phone should be sleeping unless I wake it up and my Alarms should not be sent until the phone is awake.
- Why was my service executing?
- If another service is misbehaving and using the _WAKEUP variants of the alarm will my service wake up too?
- Can I avoid being woken by another service, and just awake from the user turning the screen on?
Why was my service executing?
Presumably something else was having the device awake at those moments.
If another service is misbehaving and using the _WAKEUP variants of the alarm will my service wake up too?
Yes, though "misbehaving" is in the eye of the beholder.
Can I avoid being woken by another service, and just awake from the user turning the screen on?
Not directly via AlarmManager
. You can watch for ACTION_SCREEN_OFF
and ACTION_USER_PRESENT
broadcasts, and perhaps disable your alarms between those.
这篇关于在使用RTC报警Android上使手机的睡眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!