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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:04:42+00:00 2026-05-22T19:04:42+00:00

I am working on a GPS app. My app will fire notification by NotificationManager

  • 0

I am working on a GPS app. My app will fire notification by NotificationManager if the user go inside or outside a predefined zone. My app can fire notification for both cases.

From onResume(), I always get the latest intent.setExtra() value instead of of intent.setExtra value of the clicked notification.

The problem is how to detect the user click on the notification for inside zone or outside zone? (I want to show different view on different case)

Is it possible to add a listener for notification clicked?

Here is my code spinet:

private void displayNotificationMessage(String message, boolean vibrate, boolean playSound, Intent contentIntent, String notificationTag)
{       

    Notification notification = new Notification(R.drawable.buslogo, message, System.currentTimeMillis());

    PendingIntent myPendingIntent = PendingIntent.getActivity(this.getBaseContext(),0, contentIntent,PendingIntent.FLAG_UPDATE_CURRENT);

    notification.setLatestEventInfo(this, "Friendly Reminder", message, myPendingIntent);

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

    if (vibrate)
        notification.vibrate=new long[] {100L, 100L, 200L, 500L};

    if (playSound)
        notification.defaults |= Notification.DEFAULT_SOUND;


    notification.number = ++notificationCounter;
    notificationMgr.notify(notificationTag, notificationCounter, notification);

}

@Override
protected void onNewIntent( Intent intent ) {
    Log.i( TAG, "*********** onNewIntent(), intent = " + intent );
    if (intent.getExtras() != null)
    {
        Log.i(TAG, "in onNewIntent = " + intent.getExtras().getString("test"));
    }
    super.onNewIntent( intent );
    setIntent( intent );
}

@Override
public void onResume() {
    super.onResume();
    Log.i(TAG, "*********** Main - onResume()");

    Intent intent = this.getIntent();
    if (intent.getExtras() != null)
    {
        Log.i(TAG, "test = " + intent.getExtras().getString("test"));
    }
}

public void createNotification(String msnContent)
{
    Intent intent = new Intent();
    intent.setClass(this, Main.class);
    Bundle bundle = new Bundle(); 
    bundle.putString("test", msnContent);
    intent.putExtras(bundle);
    displayNotificationMessage(msnContent, true, true, intent, "test"); 

}
  • 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-22T19:04:43+00:00Added an answer on May 22, 2026 at 7:04 pm

    Is it possible to add a listener for notification clicked?

    Use a different PendingIntent for each case. If you are only changing an extra, be sure to use FLAG_UPDATE_CURRENT when creating the PendingIntent.

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

Sidebar

Related Questions

The app Im working on uses gps and sometimes in the onResume when the
I am working on an iphone app which needs to pop up a notification
Hi im working on an app that uses GPS location. My testing devices are
I am making an app where the user can set an alarm based on
I am working on a Widget which will get the Current GPS location and
I'm working on an iPhone app that is using GPS coordinates for leaderboards. I
I am working on a simple GPS-like app. I created a custom object which
I'm working on an Android app that uses high-resolution GPS data. It's designed to
I am currently working on an app that check for GPS data every X
I'm working on a simple app that has the following requirement: a task will

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.