Skip to content Skip to sidebar Skip to footer

Activity Isn't Picking Up New Intent

For various reasons, my app creates entries in the notification bar. When the user clicks on the notification, I want to display a custom activity that presents the entry in a cert

Solution 1:

I learned something new today: PendingIntent.getActivity may return the same PendingIntent for a given Activity. In order to create a unique PendingIntent for each unique Intent to send, you must specify the PendingIntent.FLAG_ONE_SHOT flag when creating it.

So for example, the PendingIntent creation line in my code above should have been:

PendingIntent contentIntent = PendingIntent.getActivity(applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT);

Solution 2:

I think you need to use the onNewIntent() function. It changes the intent that your Activity sees. Usage:

/**
  * onResume is called immediately after this.
  */
@Override
protected void onNewIntent(Intent intent) {
    setIntent(intent);
    resolveIntent(intent);
}

Here resolveIntent is used to actually deal with the new incoming intent. Look at documentation here.


Post a Comment for "Activity Isn't Picking Up New Intent"