开发者

Android: creating an insistent alarm (ex: morning alarm, incoming call)

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 开发者_JAVA百科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 :)


Have 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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜