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

1715 questions
39
votes
1 answer

Multiple notifications to the same activity

I have an activity that is being opened from the notification bar, but when I do NotificationManager.notify(...), I'm giving to the intent a different bundle, so that each notification opens the same activity, but obtaining from the DB other…
33
votes
2 answers

Get IntentSender object for createChooser method in Android

I would like to use new version of Intent.createChooser method which uses IntentSender. Documentation states only that I can grab it from PendingIntent instance. In my case it seems that PendingIntent won't have any other use. Is there another way…
pixel
  • 21,352
  • 30
  • 113
  • 196
30
votes
1 answer

How to use Actions from Notification without starting Activity

So I'm working on a simple music player. The music player as it names states, can play a song, pause playback, forward to next song, go back to previous song, and stop playback completely. When you play a song, there will be a notification displayed…
28
votes
11 answers

Starting app only if its not currently running

I am sending push notification to users which when clicking on it opens the app. My problem is that when the app is already open, clicking on the notification start the app again. I only want it to start the app if its not already running. I am…
Michael A
  • 5,444
  • 15
  • 62
  • 115
27
votes
3 answers

How to use PendingIntent to communicate from a Service to a client/Activity?

I have been reading the following text on the Android Developers Site, specifically under the Framework Topics -> Services -> Starting a Service. There it states the following : If the service does not also provide binding, the intent delivered…
TiGer
  • 5,789
  • 6
  • 31
  • 36
25
votes
0 answers

what is the exact difference between intent and pending intent?

Possible Duplicate: What is Pending Intent? I'm confused about intent and pending intent. Can anyone explain what exactly is the difference between both? I've searched on SO, I found this link but it didn't meet with my need:…
Android
  • 1,361
  • 2
  • 12
  • 21
25
votes
3 answers

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

I'm having a problem with alarmManager and the pending intent with extras that will go along with it. If I set multiple alarms, they will go off, however the extras stay the same. I have already read into these questions: android pending intent…
ninjasense
  • 13,382
  • 17
  • 71
  • 91
24
votes
2 answers

Android PendingIntent take you to an already existing activity?

Wasn't really sure how to search for this... I have a the following which is called whenever a job is added or removed from my queue to put a notification in the status bar: private void showNotification() { int jobsize = mJobQueue.size(); …
24
votes
2 answers

How to get and cancel a PendingIntent?

I have an alarmManager which I am using to send notifications to the user at specific times. Since there are multiple alarms, I have multiple pending intents that I am creating and giving a unique ID, However there are certain situations in which I…
ninjasense
  • 13,382
  • 17
  • 71
  • 91
24
votes
9 answers

Android - Clear task flag not working for PendingIntent

I have a task stack of A > B > C. I am currently on C, and then I press the home button. I get a notification with the intent to take me to Activity A. I press the notification, and I'm at A but if I press back, I go to C, then B, then A. I am…
user2676468
24
votes
2 answers

How to use "goAsync" for broadcastReceiver?

Background Starting with Honeycomb (API 11) , Android has a feature to allow the broadcastReceiver run in an async way, providing it about 10 seconds before it assumes it can kill its process, using a method called "goAsync" : This can be called by…
android developer
  • 106,412
  • 122
  • 641
  • 1,128
22
votes
2 answers

How does android compare pending intents

Documentation for PendingIntent.FLAG_NO_CREATE reads: Flag indicating that if the described PendingIntent does not already exist, then simply return null instead of creating it. My question: What criteria are used to compare PendingIntents? I'm…
Steven Wexler
  • 14,113
  • 7
  • 42
  • 75
22
votes
3 answers

putExtra using pending intent not working

I have written a code in my GCMIntentservice that sends push notifications to many users. I use the NotificationManager that will call DescriptionActivity class when the notification is clicked. I also send the event_id form the GCMIntentService to…
21
votes
5 answers

How to create different pendingintent so filterEquals() return false?

I'm using AlarmManager to set up repeating intents but it has caused some little troubles so hope anyone could help. Summary There are 2 pending intents. One runs at 1000 and another runs at 2000 every day. Each contains a row id from the database…
markbse
  • 963
  • 3
  • 11
  • 26
21
votes
5 answers

Intent to resume a previously paused activity (Called from a Notification)

I'm developing an app which shows a notification to the user. The notification's objective is to make it easy to the user to return to the activity when the user is in another activity. I am using this code in my app to create and show the…
Jimix
  • 1,499
  • 3
  • 15
  • 20