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
8
votes
1 answer

Pending intent with ONE_SHOT flag

Currently I've got this code: public static void setupAlarm(Context context) { Intent myIntent = new Intent(context, Receiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, myIntent,…
greywolf82
  • 21,813
  • 18
  • 54
  • 108
8
votes
1 answer

Passing data with a PendingIntent

I am attempting to raise a notification that a message has arrived. I have added an action expecting an icon (smallredball) to show on the notification. I expect that if the user hits smallredball, main activity will startup and the activity,…
Dean Blakely
  • 3,535
  • 11
  • 51
  • 83
8
votes
2 answers

How to persistently save PendingIntent provided by another application

let's say I want to implement an app which exposes services to other apps (like Google Play Services..). potential apps would register to my special events associated with my services, and would be notified at the right time. I was thinking to…
Tal Kanel
  • 10,475
  • 10
  • 60
  • 98
8
votes
1 answer

'startactivity called from non-activity context service' warning when launching intent from notification

I've a service which starts a notification with startForeground(), I want the notification to launch an activity on click. The acitivty I want to launch defined as android:launchMode="singleTask" and usually runs before the service starts. Here is…
SagiLow
  • 5,721
  • 9
  • 60
  • 115
8
votes
1 answer

Show Dialog using PendingIntent

I am working on Calender Events reminder . There is no native Calender events reminder in Android so user install different calender apps. Now these apps can be different on reminding events like on reminder notifications can be shown. Now I want…
User42590
  • 2,473
  • 12
  • 44
  • 85
8
votes
2 answers

Android: PendingIntent from Notification doesn't trigger the onCreate() if bringing Activity back on Screen

guess I'm having some misunderstandigs with the Intent Flags.. What I'm trying to do is, I'm having a radio streaming applications, which has two Activities (PlayerApplication and SettingsScreen). I have a Service.class for Streaming which runs in…
longi
  • 11,104
  • 10
  • 55
  • 89
8
votes
1 answer

Passing values in Pending Intents Android

Can we pass the arguments in a pending intent for the Background Process.. Intent ij = new Intent(context,DemoActivity.class); PendingIntent operation = PendingIntent.getActivity(getBaseContext(),0,ij,Intent.FLAG_ACTIVITY_NEW_TASK); …
8
votes
1 answer

PendingIntent scheduled using AlarmManager.RTC type is still invoked in the sleep mode

Here is the code that I used to set an alarm for my widget: private static void setAlarm(Context context) { Intent myIntent = new Intent(context, Widget.class); myIntent.setAction(AUTO_UPDATE); PendingIntent pendingIntent = …
SAbbasizadeh
  • 730
  • 10
  • 25
8
votes
2 answers

Is it necessary to use FLAG_ACTIVITY_NEW_TASK in a Notification's PendingIntent?

I have been using Notifications for a while, and yesterday I noticed that the documentation of PendingIntent says that the Intent that is passed to the PendingIntent.getActivity()method must have the FLAG_ACTIVITY_NEW_TASK set: Note that the…
7
votes
2 answers

Get user number using intent request not working?

I am justing trying to get phone number using GetPhoneNumberHintIntentRequest to replace HintRequest. So just trying to follow google developer doc https://developers.google.com/identity/phone-number-hint/android#kotlin_2. But after following doc I…
duggu
  • 37,851
  • 12
  • 116
  • 113
7
votes
3 answers

Cannot send pending intent from widget, SendIntentException

I want to send a broadcast from my widget with this code: for (int i = 0; i < N; i++) { int appWidgetId = appWidgetIds[i]; RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget); Intent x = new Intent(); if…
Force
  • 6,312
  • 7
  • 54
  • 85
7
votes
0 answers

Xiaomi Android 11 SecurityException Too many PendingIntent created

Our application has been receiving this new kind of crash since the beginning of the year. Firebase shows it repeats only on Xiaomi with Android 11. It repeats in different parts of the application. And it seems unrelated to the application code. So…
Ivan Shafran
  • 591
  • 2
  • 17
7
votes
0 answers

Android: Clicking Grouped Notifications Restarts App

I am trying to solve an issue that I am experiencing with notifications. In my app, I am creating a notification (with an indeterminate progress and a randomly generated integer code) when someone clicks a list item to download a file. On the…
JPM
  • 1,482
  • 5
  • 18
  • 25
7
votes
2 answers

PendingIntent is not working on Android O

I have download notification in my application. I've added "Cancel" button to NotificationCompat.Builder by calling addAction() method. But button not working on Android O device. When I press "Cancel" button nothing happens. But button working on…
7
votes
1 answer

Get Intent from PendingIntent causes SecurityException

We have some old code that worked for a long time: public static Intent getIntent(PendingIntent pendingIntent) { Intent intent = null; try { Method getIntent = PendingIntent.class.getDeclaredMethod("getIntent"); intent =…
Andrew
  • 664
  • 13
  • 32