Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: How to restart an activity within a tabhost?
    primarykey
    data
    text
    <p>I've searched and I know it seems some people frown upon using activities within tabs, but moving past that...how would I restart a tabbed activity while still keeping the tabs visible? I have an activity in a tab, I use the menu to create a new activity to update the tab's activity displayed info, when I return from the menu activity I want the new information to be displayed in the tab's activity. I am using startActivityForResult() from the menu choice, but when I return and try to restart the activity...it wipes out the tabs above(I guess as expected, but I want to re-launch the refreshed activity within the tab).</p> <p>Creating the tabs:</p> <pre><code> TabHost host = getTabHost(); Intent home_intent = new Intent(constants.HOME_ACTION, null, this, homeTab.class); Intent inbox_intent = new Intent(constants.INBOX_ACTION, null, this, inboxTab.class); Intent stats_intent = new Intent(constants.STATS_ACTION, null, this, infoTab.class); host.addTab(host.newTabSpec(constants.HOME_TAG) .setIndicator(getText(R.string.home_label), getResources().getDrawable(R.drawable.icon)) .setContent(home_intent)); host.addTab(host.newTabSpec(constants.INBOX_TAG) .setIndicator(getText(R.string.inbox_label), getResources().getDrawable(R.drawable.icon)) .setContent(inbox_intent)); host.addTab(host.newTabSpec(constants.STATS_TAG) .setIndicator(getText(R.string.stats_label), getResources().getDrawable(R.drawable.icon)).setContent( stats_intent)); </code></pre> <p>Return from the menu activity in the tab's activity(updating database info):</p> <pre><code> public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch(requestCode) { case (constants.ACTIVITY_REQUEST_CODE_UPDATE_PROFILE) : { if (resultCode == Activity.RESULT_OK) { boolean profileUpdated = data.getBooleanExtra(constants.ACTIVITY_BUNDLE_UPDATE_PROFILE, false); Log.d(LOG_TAG, "activity returned with " + profileUpdated); // Check to see if we updated our profile to refresh the screen if(profileUpdated == true){ // Refresh the screen with the new info homeTab.this.finish(); this.startActivity(getIntent()); } } break; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload