Questions tagged [android-pendingintent]

An Android class that provides a description of an Intent and target action to perform with it

From the PendingIntent API:

A description of an Intent and target action to perform with it. Instances of this class are created with getActivity(Context, int, Intent, int), getActivities(Context, int, Intent[], int), getBroadcast(Context, int, Intent, int), and getService(Context, int, Intent, int); the returned object can be handed to other applications so that they can perform the action you described on your behalf at a later time.

By giving a PendingIntent to another application, you are granting it the right to perform the operation you have specified as if the other application was yourself (with the same permissions and identity). As such, you should be careful about how you build the PendingIntent: often, for example, the base Intent you supply will have the component name explicitly set to one of your own components, to ensure it is ultimately sent there and nowhere else.

Useful links

1881 questions
9
votes
2 answers

Notification PendingIntent Intent extras are overridden by another notification

When creating a new notification with a new PendingIntent, the extras in its intent override any previous notification's PendingIntent Intent extras. For example, lets say I create Notification1 with PendingIntent1, which has Intent1 and its…
b.lyte
  • 6,518
  • 4
  • 40
  • 51
9
votes
1 answer

PendingIntent get requestCode

I use an AlarmManager to start a service. When i set up the AlarmManager i use the PendingIntent and use a unique requestCode which is equal to a id row in my database. PendingIntent pendingIntent = PendingIntent.getBroadcast(SettingsActivity.this, …
9
votes
1 answer

Google location API: request location updates with pending intent?

I have started to implement the Google Location API using this tutorial. I've managed to get it to work in my application quite fine, it updates my location at the right intervals etc. Now I am working on how to update my location when the device is…
9
votes
4 answers

How to abort BroadcastReceiver in android

I am making an SMS schedule app which will simply take time, sms and number from user and send this sms at a given time. I am using PendingIntent. Here is my sample code. When user creates a schedule, it simply calls this method. private void…
9
votes
4 answers

How to get notified when a notification is notified

I want to read/access/log the notifications fired on notification bar by other applications. I searched Intents and PendingIntents a lot, but couldn't get a solution. Does my application need to be notified when any notification is fired? Or Does…
9
votes
4 answers

Open android app from PUSH notification

Got a little problem that's been bugging me.. I've set up my application to receive PUSH notifications from Urban Airship and that all works fine, but when I tap on a notification in the notifications center, nothing happens. I want my app to open…
8
votes
3 answers

New PendingIntent updates current intent

i am trying to show different notifications after some time interval but what happens is it updates the current PendingIntent by the new one as a result i get only single notification even if i fire 4 - 5 pending intents requests On button click i…
Mahesh
  • 1,257
  • 1
  • 14
  • 24
8
votes
1 answer

AlarmManager object after turning off and on the phone

In my app, I set an alarm AlarmManager alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); ... PendingIntent pendingIntent = PendingIntent.getBroadcast(context, id, intent,…
yildirimyigit
  • 3,013
  • 4
  • 25
  • 35
8
votes
2 answers

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE although I'm not using any pendingIntent in application

I have already found similar answers for this but nothing work with my problem as I am getting this exception as- Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a…
8
votes
7 answers

Android paho mqtt crashes Android 12 - Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE

I am using 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5' for mqtt service and the app keeps crashing on android 12 devices with the following crash logs java.lang.IllegalArgumentException: app id: Targeting S+ (version 31 and above)…
Joseph Ofem
  • 304
  • 2
  • 15
8
votes
2 answers

Missing PendingIntent mutability flag giving warning after checking sdk version

Hey I am getting warning for pending intent. So I surrounded for check of checking sdk according to this question and this medium post. I am getting warning message Missing PendingIntent mutability flag val pendingIntent: PendingIntent = if…
Kotlin Learner
  • 3,995
  • 6
  • 47
  • 127
8
votes
2 answers

How to call a non-activity method on Notification Click

I have a java class MyClass which contains a method called callMethod. I want to call this method when user clicks on the notification Below is the code i used to generate the notification public class MainActivity extends AppCompatActivity { …
Ezio
  • 2,837
  • 2
  • 29
  • 45
8
votes
2 answers

Android 7 intent extras missing

Does anyone know if there are any changes to how Android 7.0 (Nougat) handles intent extras compared to Android 6.0 (Lollipop)? Long story short: my app works as intended on all versions from 4.1(16) to 6.0(23) but crashes on android 7.0(24)! The…
8
votes
2 answers

Unable to set repeat alarm on boot time

I got notification at 10:30 PM. But when my device is switch off at 10:30 PM and then after i switch on my device at 11:00 PM i didnt get pending notification. So i dont understand whats the problem is. any help will appreciated. Here is my code in…
Akash Patel
  • 2,757
  • 1
  • 22
  • 30
8
votes
1 answer

android How to open last activity when tapping notification

I have observed several similar questions but they couldn`t help me. I need to display last activity when user click notification. Here is my code: NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(YourService.this) …
nAkhmedov
  • 3,522
  • 4
  • 37
  • 72