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
48
votes
6 answers

Pending intent in notification not working

Below is my block of code which should open NotificationActivity when the notification is tapped on. But its not working. private void setNotification(String notificationMessage) { Uri alarmSound =…
prashantwosti
  • 980
  • 2
  • 7
  • 17
42
votes
4 answers

Delete alarm from AlarmManager using cancel() - Android

I'm trying to create and delete an alarm in two different methods which are both called at different moments in the application logic. However when I call AlarmManager's cancel() method, the alarm isn't deleted. Here's my addAlarm() Method…
Mike Bryant
  • 2,455
  • 9
  • 39
  • 60
40
votes
8 answers

Extract notification text from parcelable, contentView or contentIntent

So I got my AccessibilityService working with the following code: @Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { …
Force
  • 6,312
  • 7
  • 54
  • 85
40
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…
36
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
  • 24,905
  • 36
  • 149
  • 251
31
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…
30
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,770
  • 16
  • 75
  • 127
29
votes
3 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
  • 114,585
  • 152
  • 739
  • 1,270
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,879
  • 6
  • 35
  • 36
26
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,756
  • 19
  • 75
  • 92
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,469
  • 3
  • 13
  • 21
25
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(); …
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,756
  • 19
  • 75
  • 92
25
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 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
  • 16,589
  • 8
  • 53
  • 80