How can I correctly pass unique extras to a pending intent?

Possibly two different issues here: 1) If you’ve already created your PendingIntent before and it “matches” an existing PendingIntent, then you must specify the PendingIntent.FLAG_UPDATE_CURRENT flag or it will not pass the extras. A “match” is based on the criteria that Intent.filterEquals() uses, so definitely read the docs there and make sure you understand the … Read more

Android cannot pass intent extras though AlarmManager

UPDATE: Please see Vincent Hiribarren’s solution Old Answer… Haresh’s code is not the complete answer… I used a Bundle and I tried without Bundle but I got null’s either way when I attempting to obtain the strings from the extra’s !! The exact problem, in your code, is with the PendingIntent ! This is wrong … 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 PendingIntent extras, not received by BroadcastReceiver

I guess there are some issues with registering and unregistering in the code. Instead I registered the two BroadcastReceivers in the AndroidManifest.xml file and was able to successfully pass extras. AndroidManifest.xml <?xml version=”1.0″ encoding=”utf-8″ ?> <manifest xmlns:android=”http://schemas.android.com/apk/res/android” package=”com.myexample” android:versionCode=”1″ android:versionName=”1.0″> <uses-sdk android:minSdkVersion=”16″ android:targetSdkVersion=”17″ /> <uses-permission android:name=”android.permission.READ_CONTACTS” /> <uses-permission android:name=”android.permission.READ_PHONE_STATE” /> <uses-permission android:name=”android.permission.SEND_SMS” /> <uses-permission android:name=”android.permission.RECEIVE_SMS” … Read more

Delete alarm from AlarmManager using cancel() – Android

Try this flag: PendingIntent.FLAG_UPDATE_CURRENT Instead of: PendingIntent.FLAG_CANCEL_CURRENT So the PendingIntent will look like this: PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, alert.idAlert, intent, PendingIntent.FLAG_UPDATE_CURRENT) (Make sure that you use same alert object and mContext!) A side note: If you want one global AlarmManager, put the AlarmManager in a static variable (and initialize it only if it’s null).

What is an Android PendingIntent?

A PendingIntent is a token that you give to a foreign application (e.g. NotificationManager, AlarmManager, Home Screen AppWidgetManager, or other 3rd party applications), which allows the foreign application to use your application’s permissions to execute a predefined piece of code. If you give the foreign application an Intent, it will execute your Intent with its … Read more