@Override
  protected void onSaveInstanceState(Bundle outState) {

    super.onSaveInstanceState(outState);

    ActionBar actionBar = getActionBar();

    if (actionBar != null && actionBar.getTabCount() > 1)
      outState.putInt(getString(R.string.key_tab), actionBar.getSelectedTab().getPosition());
  }
  /** Hides every tab and shows search UI for phone lookup. */
  private void enterSearchUi() {
    if (mSearchFragment == null) {
      // We add the search fragment dynamically in the first onLayoutChange() and
      // mSearchFragment is set sometime later when the fragment transaction is actually
      // executed, which means there's a window when users are able to hit the (physical)
      // search key but mSearchFragment is still null.
      // It's quite hard to handle this case right, so let's just ignore the search key
      // in this case.  Users can just hit it again and it will work this time.
      return;
    }
    if (mSearchView == null) {
      prepareSearchView();
    }

    final ActionBar actionBar = getActionBar();

    final Tab tab = actionBar.getSelectedTab();

    // User can search during the call, but we don't want to remember the status.
    if (tab != null && !DialpadFragment.phoneIsInUse()) {
      mLastManuallySelectedFragment = tab.getPosition();
    }

    mSearchView.setQuery(null, true);

    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    sendFragmentVisibilityChange(mViewPager.getCurrentItem(), false);

    // Show the search fragment and hide everything else.
    mSearchFragment.setUserVisibleHint(true);
    final FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.show(mSearchFragment);
    transaction.commitAllowingStateLoss();
    mViewPager.setVisibility(View.GONE);

    // We need to call this and onActionViewCollapsed() manually, since we are using a custom
    // layout instead of asking the search menu item to take care of SearchView.
    mSearchView.onActionViewExpanded();
    mInSearchUi = true;
  }
 @Override
 public Tab getSelectedTab() {
   android.app.ActionBar.Tab selected = mActionBar.getSelectedTab();
   return (selected != null) ? (Tab) selected.getTag() : null;
 }
 // This method returns the currently selected tab if in tabbed navigation mode and there is at
 // least one tab present
 public Tab GetSelectedTab() {
   ActionBar actionBar = this.controls.activity.getActionBar();
   ActionBar.Tab tab = actionBar.getSelectedTab();
   return tab;
 }