Android - How to set system Alarm Clock from my ow

2019-01-26 18:06发布

问题:

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.