Android:创建持续闹钟(例如:早晨闹钟、来电)
我正在编写一个基于警报的应用程序,并且正在寻找一种方法来坚持唤醒用户。理想情况下,我希望手机能够振动、响铃并显示消息。我尝试了几种不同的选项,这就是我目前所拥有的:
让后台服务启动一个振动和振动的活动。播放音乐。
<块引用>问题:即使使用 WAKE_LOCK,用户似乎仍然需要打开屏幕并解锁才能查看我的活动
使用 AlarmManager 与 RTC_WAKEUP 和广播接收器来启动上述活动
<块引用>同样的问题
只需弹出一个通知,用户可以单击该通知来查看活动
<块引用>问题:仍然是同样的问题,而且我也无法收到振动和响铃的通知,并且经常重复直到被取消
我真正想要的是具有类似于基本 Android 早上闹钟或类似于接听电话的行为通话:无论您的手机处于唤醒还是睡眠状态,它都会响铃、振动并显示消息、照片等信息...
任何有关使用方向的提示将不胜感激!我确信我见过闹钟应用程序或“假电话”应用程序做类似的事情,但我没有主意。
干杯
ps:在这个应用程序的上下文中,我认为以这种方式唤醒用户是合理的。谨慎的通知是不合适的 - 除非你可以被一次振动唤醒:)
I'm writing an alarm-based application, and I'm looking for a way to wake up the user insistently. Ideally, I'd like the phone to vibrate, ring, and display a message. I tried a few different options, here's what I have for the moment:
Have the background service start an activity that vibrates & plays music.
problem: even with a WAKE_LOCK, it seems that the user still has to turn on the screen and unlock it to see my activity
Use the AlarmManager with RTC_WAKEUP and a broadcast receiver to start the aforementioned activity
same issue
Simply pop up a notification, which the user can click to see the activity
problem: stil the same issue, and also I can't get the notification to vibrate and ring, and repeat often until dismissed
What I would really like is to have a behaviour similar to the basic Android morning alarm, or similar to receiving a phone call: regardless of whether your phone is awake or sleeping, it rings, vibrates and displays information such as a message, a photo...
Any tips on the direction to use would be greatly appreciated! I'm sure I've seen alarm apps or "fake phone call" apps do something similar, but I'm out of ideas.
Cheers
ps: in the context of this application, I think it would be reasonable to wake up the user this way. A discreet notification would not be appropriate - unless you can wake up to a single vibration :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您查看过
ACQUIRE_CAUSES_WAKEUP
标志吗?看起来它应该做你想做的事。请参阅此处了解更多信息: http://developer.android.com/reference/android /os/PowerManager.htmlHave you looked at the
ACQUIRE_CAUSES_WAKEUP
flag? It looks like it should do what you want. See here for more information: http://developer.android.com/reference/android/os/PowerManager.html