Set android alarm clock programmatically

前端 未结 3 2015
执笔经年
执笔经年 2020-12-13 07:28

I\'m trying to build a personal app that will set alarms in the DeskClock app. I can get it to set alarms for anytime in the current day, But how would I go about setting an

3条回答
  •  一个人的身影
    2020-12-13 08:31

    Like a real alarm clock, I don't see a way to set an alarm for a future date. I think this requires one of two options:

    1. A combination of AlarmManager (to trigger an app service on the desired future date to create the alarm in AlarmClock) and then AlarmClock (to actually handle the alarm). Don't forget to listen for BOOT_COMPLETED broadcast to reset the AlarmManager alarms since they don't persist after a reboot.

    2. Use AlarmManager to trigger an app service and UI that simulates an alarm. This will require you to consider phone state and etc things you don't have to worry about with AlarmClock.

    I think you can make your app just bring up the AlarmClock dialog which allows the user to set recurring alarms and other options you cannot perform through the intent.

提交回复
热议问题