android-alarms

Android Set Multiple Alarms

拟墨画扇 提交于 2019-11-26 03:56:16
问题 I\'m trying to implement an Android app that needs to alarm (or to alert) multiple times along the time. I\'ve already searched, but the nearest I found was a fixed-number of alarms set, and I guess the example didn\'t work. What I want to know if there is exists an approach to dynamically set multiple alarms, like an Array of alarms and then to trigger those alarms in their specific timestamps. 回答1: If you want to set multiple alarms (repeating or single), then you just need to create their

does Alarm Manager persist even after reboot?

浪尽此生 提交于 2019-11-26 03:39:14
问题 I am really new to android, I have been researching about alarms. I want to alarm if there is a birthday on that day. I\'ve have used alarm manager. I was confused because i have read that it clears after reboot. I don\'t have an android phone so I\'m just using the emulator. Here\'s my code : public void schedAlarm() { AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); Intent intent = new Intent(this, AlarmService.class); pendingIntent = PendingIntent.getBroadcast(this,

android prevent immediate trigger of alarm service if alarm time has passed for the day

浪尽此生 提交于 2019-11-26 01:28:17
问题 The reference for Alarm Manager says that If the stated trigger time is in the past, the alarm will be triggered immediately. I am facing this problem in my application. Here is my alarm manager code : Intent myIntent = new Intent(getActivity(), DinnerAlarmReceiver.class); pendingDinnerIntent = PendingIntent.getBroadcast(getActivity(), 0, myIntent, 0); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, hourOfDay); calendar.set(Calendar.MINUTE, minute); alarmManager

Android: How to use AlarmManager

橙三吉。 提交于 2019-11-25 22:46:20
问题 I need to trigger a block of code after 20 minutes from the AlarmManager being set. Can someone show me sample code on how to use an AlarmManager in ِAndroid? I have been playing around with some code for a few days and it just won\'t work. 回答1: "Some sample code" is not that easy when it comes to AlarmManager . Here is a snippet showing the setup of AlarmManager : AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent i=new Intent(context, OnAlarmReceiver