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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:44:35+00:00 2026-06-15T22:44:35+00:00

I have 2 Notifications : one for incoming messages, one for outgoing messages. On

  • 0

I have 2 Notifications: one for incoming messages, one for outgoing messages. On Notification click, it sends the PendingIntent to self. I put in an extra value to determine which of the Notifications was clicked:

private static final int INID = 2;
private static final int OUTID = 1;

private void update(boolean incoming, String title, String message, int number) {
    notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    Intent intent = new Intent(this, Entry.class);
    intent.putExtra((incoming ? "IN" : "OUT"), incoming);
    PendingIntent pi = PendingIntent.getActivity(Entry.this, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
    Notification noti = new Notification(incoming ? R.drawable.next : R.drawable.prev, incoming ? "Incoming message" : "Outgoing message", System.currentTimeMillis());
    noti.flags |= Notification.FLAG_NO_CLEAR;
    noti.setLatestEventInfo(this, title, message, pi);
    noti.number = number;
    notificationManager.notify(incoming ? INID : OUTID, noti); 
}

And capture the Intent in the onNewIntent method:

@Override
protected void onNewIntent(Intent intent) {
    setIntent(intent);
    if (intent.getExtras() != null) 
        for (String id : new ArrayList<String>(intent.getExtras().keySet())) {
            Object v = intent.getExtras().get(id);
            System.out.println(id + ": " + v);
        }
    else
        log("onNewIntent has no EXTRAS");
}

plus the manifest line that makes sure that there’s only one task (in activity tag):

android:launchMode="singleTop" 

I logged that it runs through the onNewIntent method, but always use the same intent (IE if I click either the IN or OUT notification, the intent extra always contains the same bundle(logs: OUT: false)). It’s always the Intent that was created last, which I found out because the initialization of both intents happens in another sequence than when they are changed:

private void buttonClick(View v) {      
    update(true, "IN", "in", 1);
    update(false, "OUT", "out", 3);
}

private void setNotificationSettings() {
    update(false, "IN", "===out message===", 0);
    update(true, "OUT", "===in message===", 0);
}

Why do I always receive the same (last created) Intent?

  • 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-06-15T22:44:36+00:00Added an answer on June 15, 2026 at 10:44 pm

    You are passing same requestcode for all intent that why you reciev last intent everytime, so you have to pass different requestcode in pending intent..

    like as below code

    Your code:

     PendingIntent pi = PendingIntent.getActivity(Entry.this, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
    

    Need to change:

    PendingIntent pi = PendingIntent.getActivity(Entry.this, your_request_code, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code like: @notifications = Notification.find_all_by_user_id(@user.id, :order=>'deliver_by DESC', :conditions=>deliver_by >= '#{Date.today.to_s(:db)}') logger.info @upcoming_reminders[0].inspect
I have created an activity which sends a number of notifications to status bar.
Overview I have an iOS app which sends local notifications at specific dates. I
I have a simple app that shows android notifications depending to one of three
I'm using iOS 5 and Push Notifications (with notification bar). I have received 5
I have an application with 2 services. One service is to display notifications and
I have an incoming stream of messages, and want a window that allows the
I have 3 models: Books, Notifications, and NotificationTypes. Books have notifications as the Notification
I have created one windows service which send an email notifications to users (list
I am making a notification script and currently have this to display multiple notifications

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.