android-alarms

Multiple alarms at the same time in Android

為{幸葍}努か 提交于 2019-12-02 04:27:53
I'm stuck on this problem. I've read many solutions on stack overflow but none of these have solved my problem. Here's my code: In my Main Activity, I wrote this-- this.context = this; Intent alarm = new Intent(this.context, AlarmManager.class); boolean alarmRun = (PendingIntent.getBroadcast(this.context,0,alarm, PendingIntent.FLAG_NO_CREATE) != null); if (alarmRun == false){ PendingIntent pending = PendingIntent.getBroadcast(this.context, 0, alarm, 0); AlarmManager alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarmMgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,

Alarm Expires earlier than intended when using setInexactRepeating

巧了我就是萌 提交于 2019-12-02 01:22:11
1) Sample was used for repeating alarm. 2) setInexactRepeating(60000,60000) , first one expires happens at 20 to 30 secs , rest ones expires in time i.e 60secs. 3) setInexactRepeating(1000 * 60 * 25,1000 * 60 * 25), first one expires happens at 10 to 14 mins~ , rest ones expires in time i.e 25mins . 4) Docs says "Your alarm's first trigger will not be before the requested time". Anyone experienced this before?using setExact / set and restart the alarm works well and setRepeating has problem too! 来源: https://stackoverflow.com/questions/22849474/alarm-expires-earlier-than-intended-when-using

Can I set an end time for AlarmManager in Android?

ⅰ亾dé卋堺 提交于 2019-12-01 23:09:55
I have set up an AlarmManager to go off at a specific time, and then repeat in intervals. Is it possible to tell it after how many intervals to stop? Or even at what time to stop? This is what I have so far: Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, 13); calendar.set(Calendar.MINUTE, 56); Intent intent = new Intent(this, MyService.class); alarmIntent = PendingIntent.getService(this, 0, intent, 0); alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarmMgr.setInexactRepeating(AlarmManager

Repeat alarm everyday at specific time (Alarm manager)

元气小坏坏 提交于 2019-12-01 22:08:13
问题 Hi I want my application to run at specific time daily. for this I am using below code. But it runs only for one time. Whats the mistake here how can i achieve this task. AlarmManager alarmMgr0 = (AlarmManager)getSystemService(Context.ALARM_SERVICE); Intent intent0 = new Intent(this, ActivityStarter.class); PendingIntent pendingIntent0 = PendingIntent.getBroadcast(this, 0, intent0, 0); Calendar timeOff9 = Calendar.getInstance(); timeOff9.set(Calendar.HOUR_OF_DAY, 16); timeOff9.set(Calendar

Repeat alarm everyday at specific time (Alarm manager)

笑着哭i 提交于 2019-12-01 21:38:35
Hi I want my application to run at specific time daily. for this I am using below code. But it runs only for one time. Whats the mistake here how can i achieve this task. AlarmManager alarmMgr0 = (AlarmManager)getSystemService(Context.ALARM_SERVICE); Intent intent0 = new Intent(this, ActivityStarter.class); PendingIntent pendingIntent0 = PendingIntent.getBroadcast(this, 0, intent0, 0); Calendar timeOff9 = Calendar.getInstance(); timeOff9.set(Calendar.HOUR_OF_DAY, 16); timeOff9.set(Calendar.MINUTE, 13); timeOff9.set(Calendar.SECOND, 0); alarmMgr0.setRepeating(AlarmManager.RTC_WAKEUP, timeOff9

Overwrite existing alarm

泄露秘密 提交于 2019-12-01 21:20:33
I create an alaram in my app which is calling a BroadcastReceiver to setup notifications ever day with this code: Intent intent = new Intent(Benachrichtigung.CUSTOM_INTENT); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 8); calendar.set(Calendar.MINUTE, 00); calendar.set(Calendar.SECOND, 00); alram = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alram.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), (24 * 60 * 60 * 1000),

How can create more than one alarm?

别说谁变了你拦得住时间么 提交于 2019-12-01 18:16:53
I am able to create and cancel an alarm with the code below. I want to create more than one alarm. Alarm times comes from an arraylist. In this arraylist I would like to create an alarm for each date. And presses of the cancel button will cancel only the current alarm. How can I do it? public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); setOneTimeAlarm(); buttonCancel.setOnClickListener(new Button.OnClickListener() { @Override public void onClick

Alarm Does Not Wake up my Service

本小妞迷上赌 提交于 2019-12-01 10:55:09
I have the following code, I expect that this alarm invokes my Service regardless of the state of the phone. Even if its in sleep mode, I need it to access the internet and make some network calls. Why doesn't it work when the phone is in sleep mode ? Alarm Manager Calendar cal = Calendar.getInstance(); cal.add(Calendar.SECOND, 5); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); Intent notifyintent = new Intent(this, OnAlarmReceiver.class); notifyintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notifyintent.setAction("android.intent.action.NOTIFY"); PendingIntent notifysender

Alarm Does Not Wake up my Service

跟風遠走 提交于 2019-12-01 09:27:11
问题 I have the following code, I expect that this alarm invokes my Service regardless of the state of the phone. Even if its in sleep mode, I need it to access the internet and make some network calls. Why doesn't it work when the phone is in sleep mode ? Alarm Manager Calendar cal = Calendar.getInstance(); cal.add(Calendar.SECOND, 5); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); Intent notifyintent = new Intent(this, OnAlarmReceiver.class); notifyintent.addFlags(Intent.FLAG

Reminder Functionality

核能气质少年 提交于 2019-12-01 01:10:59
In my application i am trying to set reminder and alarm on that reminder but i am not able to do so. As i don't have complete and proper knowledge of how to set reminder, edit it and delete it. As i searched on google and what i got is not easy to understand for me. I tried a code as: Main.java Calendar cal = Calendar.getInstance(); java.util.Calendar; // add minutes to the calendar object cal.set(Calendar.MONTH, 4); cal.set(Calendar.YEAR, 2011); cal.set(Calendar.DAY_OF_MONTH, 5); cal.set(Calendar.HOUR_OF_DAY, 21); cal.set(Calendar.MINUTE, 43); Intent alarmintent = new Intent