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 4260422
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:55:04+00:00 2026-05-21T05:55:04+00:00

For various reasons, my app creates entries in the notification bar. When the user

  • 0

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 certain format.

Intent intent = new Intent(applicationContext, TextMessageViewerActivity.class);
intent.putExtra("text_message", someText);
PendingIntent contentIntent = PendingIntent.getActivity(applicationContext, 0, intent, 0);
// now create a notification and post it. no fancy flags

It all boils down to sending a string via an Intent extra, and displaying that in my Activity. What happens is that the first Intent that gets delivered to my Activity gets “stuck” somehow, and all further Intents delivered to it display the only the first Intent’s extra.

public class TextMessageViewerActivity extends Activity
{
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.text_viewer);
    }

    @Override
    public void onResume()
    {
        super.onResume();

        Intent startingIntent = getIntent();
        String message = startingIntent.getStringExtra("text_message");
        String displayMessage = message != null ? message : "No message found";

        ((TextView)findViewById(R.id.text_viewer_text_id)).setText(displayMessage);
    }
}

What am I not understanding about the Android Activity lifecycle?

  • 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-21T05:55:05+00:00Added an answer on May 21, 2026 at 5:55 am

    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);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I suspect I'm doing this wrong. For various reasons, my app forces the user
I have a PHP app index.php that, for various reasons, needs to run other
I've written an iOS app which uses custom localization (for various reasons). It undefines
I'm writing an app which for various reasons involves Internet Explorer (IE7, for the
For various reasons, I have some structs I want to force to be specific
I am developing a 32 bit application in .NET that for various reasons cannot
The company has a PHP app that is in horrible condition. They want to
I know that it's not 1998, but for various reasons, I'm required to change
In my app I allow the user to go to the marketplace for various
I'm writing an app with ASP.NET MVC where, for various reasons, the navigation is

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.