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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:47:11+00:00 2026-06-12T19:47:11+00:00

I have an Activity that is defined to be singleTop so that only the

  • 0

I have an Activity that is defined to be singleTop so that only the one instance will exist.

   <activity
        android:name=".MyMainActivity"
        android:label="@string/app_name" 
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize" 
        android:launchMode="singleTop" android:multiprocess="true">

I set up a Notification Intent with some data, and include it in a PendingIntent, and send it to the Notification Manager.

Intent notificationIntent = new Intent(context, MyMainActivity.class); 
notificationIntent.setAction(MyMainActivity.CustomInternalMessageAction);
notificationIntent.putExtra(MyMainActivity.ReceiveTestMessage, rawMessageText);

...
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
mNotificationManager.notify(number, notification);  

If the actiivty is not running, the intent starts the activity via onCreate() as expected.

If The activity is running, but in the stopped state / not in foreground (like when clicking the home button), and the notification is clicked, my activity’s onNewIntent() is called as expected.

However, if the Activity is already called when it’s in the foreground, then onNewIntent() doesn’t get called.

How can I set up this notificaiton so that my singleTop Activity gets sent the intent, when it’s in the pause/stop state (and also still functions in the other cases I mentioned). I’m thinking there’s a flag to set on my notificationIntent object, but the functions of the flags aren’t really clear for the case of singleTop activities.

  • 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-12T19:47:13+00:00Added an answer on June 12, 2026 at 7:47 pm

    If your application is composed by more than one activity, the remain activities need to be defined as singleTop as well if you want to receive a onNewIntent()call when that activity is active.

    Let suppose that main activity is A and is defined as singleTop and from there you start activity B not defined as singleTop. If now you select a notification that calls your application, the application will start on activity B but onNewIntent() is not called.

    You can also override this behaviour adding the flag Intent.FLAG_ACTIVITY_CLEAR_TOP which remove activity B from stack and Activity A will recive the call on onNewIntent().

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

Sidebar

Related Questions

I have an activity defined as below: <activity android:name=com.example.ui.HomeActivity android:alwaysRetainTaskState=true/> A strange thing is
I have an Activity that should only get created once. That is, onCreate can
I have an Android activity that displays a list of log entries (using a
I have an activity with a button that sends a pre-defined email. The button
I have an activity defined thus: [Activity (Label = MyActivity)] [IntentFilter (new[]{Intent.ActionView}, Categories=new[]{Intent.CategoryDefault, Intent.CategoryBrowsable},
I'm working on an Android application. I have an activity that has this method:
I have a simple HelloWorld Activity that I try to test with an Android
I want to simply call one function that is defined in BroadClass Activity from
I have an activity with one EditText where I need to input numbers only.
I have an Activity that runs the following code (time and interval are defined):

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.