Android: Get all PendingIntents set with AlarmManager

You don’t have to keep reference to it. Just define a new PendingIntent like exactly the one that you defined in creating it. For example: if I created a PendingIntent to be fired off by the AlarmManager like this: Intent alarmIntent = new Intent(getApplicationContext(), AlarmBroadcastReceiver.class); alarmIntent.setData(Uri.parse(“custom://” + alarm.ID)); alarmIntent.setAction(String.valueOf(alarm.ID)); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); PendingIntent … Read more

Can’t stop the ringing alarm from another activity

Your architecture is broken. You don’t use a BroadcastReceiver for persistent processing. A BroadcastReceiver has a very short lifecycle, you use it to trigger other things. You’ve created a MediaPlayer instance in your BroadcastReceiver and are trying to control that in onReceive(). This is wrong. You should use a Service to manage and maintain the … Read more

Android AlarmManager – RTC_WAKEUP vs ELAPSED_REALTIME_WAKEUP

AlarmManager.ELAPSED_REALTIME_WAKEUP type is used to trigger the alarm since boot time: alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, 600000, pendingIntent); will actually make the alarm go off 10 min after the device boots. There is a timer that starts running when the device boots up to measure the uptime of the device and this is the type that triggers your alarm … Read more

How to set multiple alarms using alarm manager in android

You need to use different Broadcast id’s for the pending intents. Something like this: Intent intent = new Intent(load.this, AlarmReceiver.class); final int id = (int) System.currentTimeMillis(); PendingIntent appIntent = PendingIntent.getBroadcast(this, id, intent, PendingIntent.FLAG_ONE_SHOT); Using the system time should be a unique identifier for every pending intent you fire.

does Alarm Manager persist even after reboot?

A simple answer would be NO. But yes you can achieve this by creating a BroadCastReceiver which will start the Alarm while booting completes of the device. Use <action android:name=”android.intent.action.BOOT_COMPLETED” /> for trapping boot activity in BroadCastReceiver class. You need to add above line in AndroidManifest.xml as follows, <receiver android:name=”.AutoStartUp” android:enabled=”true” android:exported=”false” android:permission=”android.permission.RECEIVE_BOOT_COMPLETED”> <intent-filter> <action … Read more

Android: keeping a background service alive (preventing process death)

For Android 2.0 or later you can use the startForeground() method to start your Service in the foreground. The documentation says the following: A started service can use the startForeground(int, Notification) API to put the service in a foreground state, where the system considers it to be something the user is actively aware of and … Read more