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

  • Home
  • SEARCH
  • 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 6053511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:02:54+00:00 2026-05-23T08:02:54+00:00

I currently have a Tab screen in my application. I use a notification to

  • 0

I currently have a Tab screen in my application. I use a notification to notify the user of a state change in my application and in normal circumstances when the user clicks on the notification it will return to this tab screen.

Here is the code I use for this:

        String ns = Context.NOTIFICATION_SERVICE;
        mNotificationManager = (NotificationManager) context.getSystemService(ns);

        Intent notificationIntentRegState = new Intent();
        ComponentName cn = new ComponentName(context, TabScreenActivity.class);
        notificationIntentRegState.setComponent(cn);

        contentIntentRegState = PendingIntent.getActivity(context, 0, notificationIntentRegState, 0);
        notificationRegStateText = context.getString(R.string.app_name);
        notificationRegState = new Notification(icon, notificationRegStateText, 0);

        notificationRegState.setLatestEventInfo(context, notificationRegStateText, context.getString(R.string.notification_text, contentIntentRegState);
        mNotificationManager.notify(3, notificationRegState);   

However in my application the user can start another activity from the TabScreen and when this activity is “active” I want the notification to bring the user to the new activity and not the tabscreen activity. But when the notification is clicked it always goes to the Tab screen.

Is it possible to make sure the notification always directs the user to the most recent activity?

  • 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-23T08:02:54+00:00Added an answer on May 23, 2026 at 8:02 am

    You could recreate the last activity that has been created by user, in response to notification beeing clicked.

    in your pending activity, you could add an extra data to remmeber which activity to show :

    Intent notificationIntentRegState = new Intent( "showTabScreen" );
    ComponentName cn = new ComponentName(context, TabScreenActivity.class);
    notificationIntentRegState.setComponent(cn);
    notificationIntentRegState.putExtra( CURRENT_ACTIVITY, getCurrentActivityId() );
    

    where getCurrrentActivityID() returnin a constant that you use to identify the last activity launched.

    And, in the onCreateMethod of your tabScreen, you could check the intent that you received and the extra param to launch that activity again in response to a click on notification

    @Override
    public void onCreate( Bundle b )
    {
         String action = getIntent().getAction();
         if( action != null && action.equals( "showTabScreen" )  )
         {
            int activityToShow = getIntent().getIntExtra( CURRENT_ACTIVITY, -1 );
            if( activityToShow != -1 )
            {
               switch( activityToShow )
               {
                   case ACTIVITY_ID_ONE : startActivity( ActivityOne.class );
               }//switch
               startActivity();
            }//if
         }//if
    }//met
    

    With, of course, you tabScreen filtering the intent name “showTabScreen” in your manifest.xml file.

    Regards,
    Stéphane

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

Sidebar

Related Questions

I currently have an extension Method which converts an IEnumerable of type Tab into
I currently have an MS Access application that connects to a PostgreSQL database via
I currently have heavily multi-threaded server application, and I'm shopping around for a good
I currently have a functioning in-house Windows Forms application which extensively uses the DataGridView
I currently have an app that is a tab bar style app and supports
Ok I have an application that uses tab controller. However before I want the
I have an ios5 app developed using storyboards that currently displays a tab bar
I currently have a tab layout with 2 tabs, one tab with a list
I sometimes need to use Visual Studio when I have limited screen real estate
I currently have a tabview and in my first tab i have a toast

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.