Code example for TabHost

Methods: getCurrentTabTagsetCurrentTab

0
		final boolean recentCallsRequest = Calls.CONTENT_TYPE.equals(intent
				.getType());
 
		// Dismiss menu provided by any children activities 
		Activity activity = getLocalActivityManager().getActivity(
				mTabHost.getCurrentTabTag());
		if (activity != null) {
			activity.closeOptionsMenu();
		} 
 
		// Tell the children activities that they should ignore any possible 
		// saved 
		// state and instead reload their state from the parent's intent 
		intent.putExtra(EXTRA_IGNORE_STATE, true);
 
		// Remember the old manually selected tab index so that it can be 
		// restored if it is 
		// overwritten by one of the programmatic tab selections 
		final int savedTabIndex = mLastManuallySelectedTab;
 
		// Choose the tab based on the inbound intent 
		String componentName = intent.getComponent().getClassName();
		if (getClass().getName().equals(componentName)) {
			if (recentCallsRequest) {
				mTabHost.setCurrentTab(TAB_INDEX_CALL_LOG);
			} else { 
				mTabHost.setCurrentTab(TAB_INDEX_DIALER);
			} 
		} else if (FAVORITES_ENTRY_COMPONENT.equals(componentName)) {
			mTabHost.setCurrentTab(TAB_INDEX_FAVORITES);
		} else if (CONTACTS_LAUNCH_ACTIVITY.equals(componentName)) {
			mTabHost.setCurrentTab(mLastManuallySelectedTab);
		} else { 
			SharedPreferences prefs = getSharedPreferences(PREFS_DIALTACTS,
					MODE_PRIVATE);
			boolean favoritesAsContacts = prefs.getBoolean(
					PREF_FAVORITES_AS_CONTACTS,
					PREF_FAVORITES_AS_CONTACTS_DEFAULT);
			if (favoritesAsContacts) {
				mTabHost.setCurrentTab(TAB_INDEX_FAVORITES);
			} else { 
				mTabHost.setCurrentTab(TAB_INDEX_CONTACTS);
			} 
		} 
 
		// Restore to the previous manual selection 
		mLastManuallySelectedTab = savedTabIndex;