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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:41:37+00:00 2026-06-16T09:41:37+00:00

I am using a local notification in my application like this. showNotification(this, Title1, Message

  • 0

I am using a local notification in my application like this.

    showNotification(this, "Title1", "Message One", 1);
    showNotification(this, "Title2", "Message Two", 2);
    showNotification(this, "Title3", "Message Three", 3);
    showNotification(this, "Title4", "Message Four", 4);


public static void showNotification(Context con, String title,
        String message, int id) {


    NotificationManager manager = (NotificationManager) con
            .getSystemService(Context.NOTIFICATION_SERVICE);

    Notification note = new Notification(R.drawable.ic_noti_logo,title, System.currentTimeMillis());

    Intent notificationIntent = new Intent(con,Result.class);
    notificationIntent.putExtra("Message", message);
    notificationIntent.putExtra("NotiId", id);

    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
            | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    PendingIntent pi = PendingIntent.getActivity(con, 0,
            notificationIntent, PendingIntent.FLAG_ONE_SHOT);

    note.setLatestEventInfo(con, title, message, pi);

    note.defaults |= Notification.DEFAULT_ALL;
    note.flags |= Notification.FLAG_AUTO_CANCEL;
    manager.notify(id, note);
}

in Resut.java

    message = getIntent().getStringExtra("Message");
    notiId = getIntent().getIntExtra("NotiId", 0);

    showAlert(message,notiId);

private void showAlert(String msg, int id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(msg).setCancelable(false)
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                //  finish();
                    cancelNotification(Result.this,id);
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

public static void cancelNotification(Context con, int id) {

    NotificationManager manager = (NotificationManager) con
            .getSystemService(Context.NOTIFICATION_SERVICE);
    manager.cancel(id);
}

my problem is that, I am getting 4 notification message in notification bar and when I am clicking any of them I am redirecting to Result Activity but it hapens only ones when second time I clicked there was no effect. please help me.

  • 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-16T09:41:38+00:00Added an answer on June 16, 2026 at 9:41 am

    The problem is that the four notifications share the same PendingIntent because they reference equivalent Intents (the docs for Intent.filterEquals() explain that to be considered distinct, Intents must differ in either action, data, class, type, or categories—note that extras are specifically not considered when determining whether Intents are equal). Furthermore, you’re using PendingIntent.FLAG_ONE_SHOT which guarantees the PendingIntent can only be used once.

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

Sidebar

Related Questions

I am working on an alarm application and I am using local notification for
I am now using local notification in an application, but I find something strange.
guys :) I'm using local notification in my application and I provide action for
HI All, i am trying to use local notification by using this NSDateComponents *dateComps
I'm using Xcode 4.3.2, How can i set this local notification dateToFire everyday at
I am using Local notification in my application. Now if i remove my application
Using local variables seems advisable in a partial that could be used application-wide to
I have a JEE5 application that exposes services using (local) session beans. When an
I am having trouble constructing a jqGrid TreeGrid using local data. This method works
I'm using a local shared object as means to transfer data between two swf's

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.