Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6193129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:03:54+00:00 2026-05-24T03:03:54+00:00

I have a program in which I call a notification. The notification, if you

  • 0

I have a program in which I call a notification. The notification, if you pull it down, launches a new activity.

mNotificationManager = (NotificationManager) getSystemService(ns);

int icon = R.drawable.stat_sys_secure_green;
CharSequence tickerText = "Browser Security Enabled";
long when = System.currentTimeMillis();

notification = new Notification(icon, tickerText, when);

Context context = getApplicationContext();
CharSequence contentTitle = "Browser Security";
CharSequence contentText = "Security Vulnerability Detected";
Intent notificationIntent = new Intent(this, PrivacyMessage.class);

//Test Extra
notificationIntent.putExtra("Primary Key", "Primary Text");

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

mNotificationManager.notify(HELLO_ID, notification);

The problem comes later in the code, when I want to refresh the secondary activity. The main activity should be able to dynamically change the extras in it. I tried doing this by launching a new intent.

CharSequence contentTitle = "Browser Security";
CharSequence contentText = "Test New Notification";
Intent intent = new Intent(this, PrivacyMessage.class);
notification.icon = R.drawable.stat_sys_secure_orange;

intent.putExtra("Test Thing", "Test Value");
//intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

PendingIntent cI = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(getApplicationContext(), "New Title", "NewText", cI);
mNotificationManager.notify(HELLO_ID, notification);

Now, when I execute that code, the new notification title pops up, the icon color changes, and the pulldown reflects the new title and addition information. However, when I click on it, it does not launch the activity with the new intent. Instead, it just pulls out the old activity with the old extras. I tried both FLAG_ACTIVITY_CLEAR_TOP, and FLAG_ACTIVITY_NEW_TASK, but neither one seems to clear the old secondary activity and create a new one. Any idea on how I might do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:03:56+00:00Added an answer on May 24, 2026 at 3:03 am

    Apparently this is actually a bug/feature of the android environment. Unless a pendingIntent() is passed with a unique requestCode, it simply retrieves the old intent that was originally passed with that number.

    Details can be found here:
    http://groups.google.com/group/android-developers/browse_thread/thread/ad855bb57042c2bd/e84c8d6fececf6e4?lnk=gst&q=notification#e84c8d6fececf6e4

    The solution they came up with was to simply increment the requestCode every time pendingIntent.getActivity(Context context, int requestCode, Intent intent, int flags) is called, and set the flags the way I had done it originally with

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    

    Which, doesn’t seem like a perfect solution, but it works. Thank you guys for your help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program which automatically launches a phone call when program is started.
I have a program which does a system call: latex somefile.latex This runs ok,
I have a C program which has a function call that is defined in
I have a GUI program, which would call a cmd in this GUI program.
I have written a program a.exe which launches another program I wrote, b.exe ,
I have a C# program which should call Matlab for running a m-file and
I have a program which during it's run sometimes needs to call python in
I'm new with boost. I have a program which uses dynamic_bitset inside a lambda
I have a program which I need to call more than 100 times with
I have a program which needs to behave slightly differently on Tiger than on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.