/**
   * Sets the current tab based on the intent's request type
   *
   * @param intent Intent that contains information about which tab should be selected
   */
  private void setCurrentTab(Intent intent) {
    // If we got here by hitting send and we're in call forward along to the in-call activity
    final boolean recentCallsRequest = Calls.CONTENT_TYPE.equals(intent.getType());
    if (isSendKeyWhileInCall(intent, recentCallsRequest)) {
      finish();
      return;
    }

    // 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 = mLastManuallySelectedFragment;

    final int tabIndex;
    if (DialpadFragment.phoneIsInUse() || isDialIntent(intent)) {
      tabIndex = TAB_INDEX_DIALER;
    } else if (recentCallsRequest) {
      tabIndex = TAB_INDEX_CALL_LOG;
    } else {
      tabIndex = mLastManuallySelectedFragment;
    }

    final int previousItemIndex = mViewPager.getCurrentItem();
    mViewPager.setCurrentItem(tabIndex, false /* smoothScroll */);
    if (previousItemIndex != tabIndex) {
      sendFragmentVisibilityChange(previousItemIndex, false);
    }
    mPageChangeListener.setCurrentPosition(tabIndex);
    sendFragmentVisibilityChange(tabIndex, true);

    // Restore to the previous manual selection
    mLastManuallySelectedFragment = savedTabIndex;
    mDuringSwipe = false;
    mUserTabClick = false;
  }
  /**
   * Sets the current tab based on the intent's request type
   *
   * @param intent Intent that contains information about which tab should be selected
   */
  private void displayFragment(Intent intent) {
    // If we got here by hitting send and we're in call forward along to the in-call activity
    boolean recentCallsRequest =
        Calls.CONTENT_TYPE.equals(intent.resolveType(getContentResolver()));
    if (isSendKeyWhileInCall(intent, recentCallsRequest)) {
      finish();
      return;
    }

    if (mDialpadFragment != null) {
      final boolean phoneIsInUse = phoneIsInUse();
      if (phoneIsInUse || isDialIntent(intent)) {
        mDialpadFragment.setStartedFromNewIntent(true);
        if (phoneIsInUse && !mDialpadFragment.isVisible()) {
          mInCallDialpadUp = true;
        }
        showDialpadFragment(false);
      }
    }
  }