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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:27:03+00:00 2026-05-18T12:27:03+00:00

I have three activities: Activity A – Displays a list of data from a

  • 0

I have three activities:

Activity A – Displays a list of data from a website. From this activity you can perform an action which would add something to this list (Activity B).

Activity B – This is the activity that adds data to the website. Upon successful completion this activity will need to tell Activity A to refresh its list.

Activity T – A TabHost which contains Activity A.

My problem is:

Activity B needs to tell Activity A to refresh, but its intent must be Activity T, since I want the TabHost to display Activity A.

//ActivityB.class
Intent myIntent = new Intent(v.getContext(), ActivityT.class);
myIntent.putExtra("target", "ActivityA");
myIntent.putExtra("refreshData", true);
startActivityForResult(myIntent, 0);

I thought I could use the TabHost as an intermediary and just pass the extras through to Activity A if they were set, like so:

//ActivityT.class
Bundle extras = getIntent().getExtras();

// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, ActivityA.class);

// Check to see if we want to pass our bundle through to the activity
if (extras != null && extras.getString("target").equals("activityA")) {
     intent.putExtras(extras);
}

// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("Tab1").setIndicator("Tab1",
            res.getDrawable(R.drawable.ic_tab_tab1)).setContent(intent);
tabHost.addTab(spec);

This works great, except that when I change tabs to a different tab and change back, the extras are passed through yet again, and again – which causes my tab to refresh its data every time, even though I’m no longer coming from Activity B. This is because the TabActivity doesn’t get recreated on tab change and therefore the extras are always passed through to the child intents.

So, how I can tell Activity A to refresh ONLY from Activity B, but still get the TabHost to show up?

  • 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-18T12:27:04+00:00Added an answer on May 18, 2026 at 12:27 pm

    While perhaps not the most elegant solution, I used static data members in my ActivityA class which I can set from ActivityB.

    //ActivityA.class
    
    public static boolean refreshData = false;
    
    public void onResume() {
        if (refreshData) {
             mRefreshData();
             refreshData = false;
        }
    }
    
    //ActivityB.class
    
    ActivityA.refreshData = true;
    Intent myIntent = new Intent(v.getContext(), ActivityT.class);
    startActivityForResult(myIntent, 0);
    

    I’m interested to know if there’s a better way to do this kind of thing!

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

Sidebar

Related Questions

I have three activities, A, B and C. User can start activity B from
Possible Duplicate: Removing an activity from the history stack Suppose I have three activities
I have three activities, say I have the data from ActivityA, and I want
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three activities 1 is the main activity 2 is some other activity
I have three activities in my android app. First activity is main application screen
I have three tables: CREATE TABLE activities ( activity varchar(20) Primary key ); with
I have three activities A->B->C.when i am in B activity i click the home
I have three activities in my activity stack, A (main) -> B -> C.
I have three activities that I can call A, B and C. I want

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.