android-alarms

onNewIntent not called on restart

天大地大妈咪最大 提交于 2019-12-12 18:09:46
问题 I have an alarm clock app, that is using Alarm Manager and a Broadcast Receiver. The app is one single activity and 4 fragments. When an alarm goes off the onReceive method sends an intent to the main activity, the main activity receives this intent in the method onNewIntent and then moves to the correct fragment. Everything works fine, except when an alarm goes off after the app has been closed. Once I destroy the app, the alarm still goes off and the intent from the broadcast receiver fires

What is the best way to schedule task in android?

你说的曾经没有我的故事 提交于 2019-12-12 06:39:38
问题 My project requirement is to schedule multiple tasks very frequently at exact time with delay between 0-5 seconds. What is the best way to schedule tasks for this purpose? Below are the options I considered: 1. Alarm Manager : Using Alarm Manager I have observed alarm does not schedule below 5 seconds. Even if I am passing 3 seconds time, alarm broadcasts after 5 seconds. Below is my code : int requestCode = 101; int delayTime = 3000L; Intent intent = new Intent(context, TaskBroadcastReceiver

Alarm Manager isn't repeating after reboot

白昼怎懂夜的黑 提交于 2019-12-12 05:34:24
问题 I have problem with Alarm Manager. I create alarm manager which repeat displaying toast every 15 seconds. After rebooting my device, toast is visible, but only once. I want to repeat it again every 15 seconds even after reboot. What can I add to solve this? Is this possible? Here is my code (class AlarmReceiver extends BroadcastReceiver): @Override public void onReceive(Context context, Intent intent) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);

Android Set multiple repeat alarms

跟風遠走 提交于 2019-12-12 04:51:12
问题 I want to set 3 different alarms repeat everyday.(like 9:00am,1:00pm,6:00pm) And I have created buttons for them. I can set the alarm's time when I click the button. The problem is how can I change my code to achieve above mentioned. private void setNotification() { Intent myIntent = new Intent(getActivity(), MyReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(getActivity(), 0, myIntent, 0); AlarmManager alarmManager = (AlarmManager)getActivity().getSystemService

Set alarm for 1 min but it called after 5 minutes

痞子三分冷 提交于 2019-12-12 03:09:47
问题 I have set alarm for 1 minutes but it called after every 5 minutes. AlarmManager alarmManager = (AlarmManager)getActivity().getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(getActivity(), MyBroadcastReceiver.class); intent.setAction("com.example"); PendingIntent pendingIntent = PendingIntent.getBroadcast(getActivity(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); //pending intent alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, new Date().getTime(), 60000,

how to cancel multiple alarm using other activity

我怕爱的太早我们不能终老 提交于 2019-12-12 02:34:26
问题 Create note Activity from where Alarm trigger! and Alarm delete code in other Activity ,it delete only last trigger Alarm means if 3 Alarm are created and I want to delete Alarm 1 it deletes but when the time of Alarm 1 reaches it trigger while it already deleted and it wont trigger other Alarm 2 and 3 , on static broadcast id it trigger only last alarm for example alarm 3 trigger delete code in other activity if it delete on using same pending intent in other activity how can i use the

Alarm manager: repeating alarm not always fires

别等时光非礼了梦想. 提交于 2019-12-12 01:46:42
问题 I'm trying to develop a kind of reminders system, so user can enter days for reminders (MON, TUE...) and times on which this reminder will fire (only hour and minutes). It can be any day of the week or multiple days of the week. Here is the code for setting these reminders: final AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); for (final Day day: reminder.getDays()) { for (final ReminderTime reminderTime: reminder.getTimes()) { final Calendar calendar =

Why repeatingAlarm only runs for 1 time only

谁说我不能喝 提交于 2019-12-12 01:43:58
问题 I am working on repeating alarm . problem is that my repeat alarm only runs for one time only on set time but not repeat on that time next day. If it is 5/28/2015 and time is 1:40PM and I set alarm to 8:30am with repeating mode then it should repeat everyday on 8:30am but problem is that it runs on 5/29/2015 on 8:30AM but will not run on 5/30/2015 at 8:30AM and further on. Here is my code: if(AM_PMSet!=null) { Calendar gcClone = Calendar.getInstance(); Calendar gc = (Calendar) gcClone.clone()

Pending Intent Causing mainactivity to reload, why is that?

末鹿安然 提交于 2019-12-12 00:46:03
问题 I'm trying to write a service that will check every midnight for new data from the server and will download it. But when i start the app the mainActivity screen reloads after few seconds. I'v checed it and it happens because of this service, Why is this happening? Her are the files: MainActivity: i'v created an AlarmManager object to set pendingIntent: //Set alarm /* Retrieve a PendingIntent that will perform a broadcast */ Intent alarmIntent = new Intent(getApplicationContext(),

onReceive() method not opening application while device is in sleep mode..?

房东的猫 提交于 2019-12-11 18:56:10
问题 Hi friends i have a problem... Actually i use this code to open my application in certain time..the app is working fine but when the device is in sleep mode not working..?? public class MyBroadCastReceiver extends BroadcastReceiver { @Override public void onReceive(Context ctx, Intent intent) { Intent intent = new Intent(ctx, ActivityMain.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); ctx.startActivity(intent); } } ActivityMain.java