Android - How to set system Alarm Clock from my own app

荒凉一梦 提交于 2019-12-29 07:52:27

问题


I would like to set a normal, Android alarm clock in my app - the one in the default Android Clock application. I simply want to schedule a an alarm that will ring let's say tomorrow at 8 a.m. I've read about the Alarm Manager, but it seems to trigger an event, and I just want it to ring. I'm pretty sure there's an easy solution for that, but I couldn't find it. I'll apprecaite any help!


回答1:


It appears that there is no documented Intent for launching the alarm clock in the Android SDK. Having said that, here are a few resources you can try that should get you around that:

  • Intent to launch the clock application on android
  • Android AlarmClock ACTION_SET_ALARM intent produces exception
  • How does one launch android version dependent alarm clock?



回答2:


I ended up building my own ringer in the BroadcastReceiver, as zapl suggested (thanks!). Problem was, I couldn't create a dialog that would allow user to dismiss the alarm, however I was able to create a notification that does that, as the class documentation suggested.



来源:https://stackoverflow.com/questions/9618748/android-how-to-set-system-alarm-clock-from-my-own-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!