类android.support.v4.app.NavUtils源码实例Demo

下面列出了怎么用android.support.v4.app.NavUtils的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Tok-Android   文件: BaseTitleActivity.java
/**
 * default method to finish activity,
 * it can be changed by override
 */
public void onFinish() {
    if (isSupportTaskBack()) {
        moveTaskToBack(true);
    } else {
        String parentActivityName = NavUtils.getParentActivityName(this);
        if (parentActivityName != null && !SystemUtils.isActivityRunning(this,
            parentActivityName)) {
            PageJumpIn.jumpActivity(this, parentActivityName);
            finish();
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
            finishAfterTransition();
        } else {
            finish();
        }
    }
}
 
源代码2 项目: android-discourse   文件: SearchActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // This ID represents the Home or Up button. In the case of this
            // activity, the Up button is shown. Use NavUtils to allow users
            // to navigate up one level in the application structure. For
            // more details, see the Navigation pattern on Android Design:
            //
            // http://developer.android.com/design/patterns/navigation.html#up-vs-back
            //
            NavUtils.navigateUpFromSameTask(this);
        case R.id.action_search:
            L.i();
            return false;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码3 项目: Sky31Radio   文件: BaseActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Timber.i("onCreate");
    AVAnalytics.trackAppOpened(getIntent());
    setContentView(provideContentViewId());
    ButterKnife.inject(this);
    if(toolbar!=null){
        setSupportActionBar(toolbar);
    }
    if(!TextUtils.isEmpty(NavUtils.getParentActivityName(this))){
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    if(Build.VERSION.SDK_INT <= 19){
        tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setStatusBarTintColor(getResources().getColor(R.color.primary_dark));
    }
}
 
源代码4 项目: good-weather   文件: WeatherForecastActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_forecast_refresh:
            if (mConnectionDetector.isNetworkAvailableAndConnected()) {
                getWeather();
                setVisibleUpdating(true);
            } else {
                Toast.makeText(WeatherForecastActivity.this,
                               R.string.connection_not_found,
                               Toast.LENGTH_SHORT).show();
            }
            return true;
        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码5 项目: kaif-android   文件: DebatesActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case android.R.id.home:
      Intent upIntent = NavUtils.getParentActivityIntent(this);
      if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
        TaskStackBuilder.create(this).addNextIntentWithParentStack(upIntent).startActivities();
      } else {
        upIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        NavUtils.navigateUpTo(this, upIntent);
      }
      return true;
    case R.id.action_open_link:
      Intent intent = new Intent(Intent.ACTION_VIEW);
      intent.setData(article.getPermaLink());
      intent.addCategory(Intent.CATEGORY_BROWSABLE);
      this.startActivity(intent);
      return true;
  }

  return super.onOptionsItemSelected(item);
}
 
源代码6 项目: android-map_list   文件: MapActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            Intent upIntent = NavUtils.getParentActivityIntent(this);

            if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
                TaskStackBuilder.create(this)
                        .addNextIntentWithParentStack(upIntent)
                        .startActivities();
            } else {
                NavUtils.navigateUpTo(this, upIntent);
            }

            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // Navigate "up" the demo structure to the launchpad activity.
            // See http://developer.android.com/design/patterns/navigation.html for more.
            NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
            return true;

        case R.id.action_add_item:
            // Hide the "empty" view since there is now at least one item in the list.
            findViewById(android.R.id.empty).setVisibility(View.GONE);
            addItem();
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
源代码8 项目: v2ex-daily-android   文件: UserActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()){
        case android.R.id.home:
            Intent upIntent = NavUtils.getParentActivityIntent(this);
            if(NavUtils.shouldUpRecreateTask(this, upIntent)){
                TaskStackBuilder.create(this).addNextIntentWithParentStack(upIntent).startActivities();
            }else{
                upIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                NavUtils.navigateUpTo(this, upIntent);
            }
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
源代码9 项目: AndroidTrainingCode   文件: CrossfadeActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // Navigate "up" the demo structure to the launchpad activity.
            // See http://developer.android.com/design/patterns/navigation.html for more.
            NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
            return true;

        case R.id.action_toggle:
            // Toggle whether content is loaded.
            mContentLoaded = !mContentLoaded;
            showContentOrLoadingIndicator(mContentLoaded);
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
源代码10 项目: PlayMusicExporter   文件: MusicTrackListActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        NavUtils.navigateUpTo(this, new Intent(this, MusicContainerListActivity.class));
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码11 项目: wifi_backend   文件: WifiListActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final int id = item.getItemId();

    if (id == android.R.id.home) {
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
源代码12 项目: Women-Safety-App   文件: Verify.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
	case android.R.id.home:
		// This ID represents the Home or Up button. In the case of this
		// activity, the Up button is shown. Use NavUtils to allow users
		// to navigate up one level in the application structure. For
		// more details, see the Navigation pattern on Android Design:
		//
		// http://developer.android.com/design/patterns/navigation.html#up-vs-back
		//
		NavUtils.navigateUpFromSameTask(this);
		return true;
	}
	return super.onOptionsItemSelected(item);
}
 
源代码13 项目: android-discourse   文件: CategoryActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // This ID represents the Home or Up button. In the case of this
            // activity, the Up button is shown. Use NavUtils to allow users
            // to navigate up one level in the application structure. For
            // more details, see the Navigation pattern on Android Design:
            //
            // http://developer.android.com/design/patterns/navigation.html#up-vs-back
            //
            NavUtils.navigateUpFromSameTask(this);
            // finish();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码14 项目: ScreenShift   文件: SettingsActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        // TODO: If Settings has multiple levels, Up should navigate up
        // that hierarchy.
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码15 项目: XMouse   文件: SettingsActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

        case android.R.id.home:
            // This ID represents the Home or Up button. In the case of this
            // activity, the Up button is shown. Use NavUtils to allow users
            // to navigate up one level in the application structure. For
            // more details, see the Navigation pattern on Android Design:
            //
            // http://developer.android.com/design/patterns/navigation.html#up-vs-back
            //
            // TODO: If Settings has multiple levels, Up should navigate up
            // that hierarchy.
            NavUtils.navigateUpFromSameTask(this);
            return true;

    }
    return super.onOptionsItemSelected(item);
}
 
源代码16 项目: android-mvp-architecture   文件: FeedActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        // Respond to the action bar's Up/Home button
        case android.R.id.home:
            Intent upIntent = NavUtils.getParentActivityIntent(this);
            upIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
                // This activity is NOT part of this app's task, so create a new task
                // when navigating up, with a synthesized back stack.
                TaskStackBuilder.create(this)
                        // Add all of this activity's parents to the back stack
                        .addNextIntentWithParentStack(upIntent)
                        // Navigate up to the closest parent
                        .startActivities();
            } else {
                // This activity is part of this app's task, so simply
                // navigate up to the logical parent activity.
                NavUtils.navigateUpTo(this, upIntent);
            }
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码17 项目: android   文件: SettingsActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        Intent upIntent = NavUtils.getParentActivityIntent(this);
        if (NavUtils.shouldUpRecreateTask(this, upIntent) || isTaskRoot()) {
            // This activity is NOT part of this app's task, so create a new task
            // when navigating up, with a synthesized back stack.
            // This is probably because we opened settings from the notification.
            TaskStackBuilder.create(this)
                    // Add all of this activity's parents to the back stack
                    .addNextIntentWithParentStack(upIntent)
                    // Navigate up to the closest parent
                    .startActivities();
        } else {
            NavUtils.navigateUpTo(this, upIntent);
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码18 项目: ui   文件: ActionbarActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
	case android.R.id.home:
		// Navigate "up" the demo structure to the launchpad activity.
		// See http://developer.android.com/design/patterns/navigation.html for more.
		NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
		return true;

	case R.id.action_previous:
		// Go to the previous step in the wizard. If there is no previous step,
		// setCurrentItem will do nothing.
		viewPager.setCurrentItem(viewPager.getCurrentItem() - 1);
		return true;

	case R.id.action_next:
		// Advance to the next step in the wizard. If there is no next step, setCurrentItem
		// will do nothing.
		viewPager.setCurrentItem(viewPager.getCurrentItem() + 1);
		return true;
	}

	return super.onOptionsItemSelected(item);
}
 
源代码19 项目: NetworkMapper   文件: SettingsActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        // TODO: If Settings has multiple levels, Up should navigate up
        // that hierarchy.
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
	case android.R.id.home:
		// This ID represents the Home or Up button. In the case of this
		// activity, the Up button is shown. Use NavUtils to allow users
		// to navigate up one level in the application structure. For
		// more details, see the Navigation pattern on Android Design:
		//
		// http://developer.android.com/design/patterns/navigation.html#up-vs-back
		//
		NavUtils.navigateUpTo(this, new Intent(this, RecipeItemListActivity.class));
		return true;
	}
	return super.onOptionsItemSelected(item);
}
 
源代码21 项目: ui   文件: textActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
	 
	case android.R.id.home:
		 Intent upIntent = new Intent(this, Fd2v11.class);
		// This ID represents the Home or Up button. In the case of this
		// activity, the Up button is shown. Use NavUtils to allow users
		// to navigate up one level in the application structure. For
		// more details, see the Navigation pattern on Android Design:
		//
		// http://developer.android.com/design/patterns/navigation.html#up-vs-back
		//
		NavUtils.navigateUpTo(this,	upIntent);
		return true;
	}
	return super.onOptionsItemSelected(item);
}
 
源代码22 项目: ALLGO   文件: FilterEventACTIVITY.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            Intent upIntent = new Intent(this, HomeACTIVITY.class);
            if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
                TaskStackBuilder.from(this)
                        //如果这里有很多原始的Activity,它们应该被添加在这里
                        .addNextIntent(upIntent)
                        .startActivities();
                finish();
            } else {
                NavUtils.navigateUpTo(this, upIntent);
            }
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home: {
            Toast toast = Toast.makeText(
                    this, getString(R.string.shortcut_string), Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();

            // Navigate up to parent Activity and finish this
            NavUtils.navigateUpFromSameTask(this);
            return true;
        }
    }
    return super.onOptionsItemSelected(item);
}
 
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            return true;
        case R.id.toggle_select_all_menu_btn:
            for (int i=0;i<checkBoxList.size();i++) {
                checkBoxList.get(i).setChecked(!isSelectedAll);
            }
            isSelectedAll = !isSelectedAll;
            return true;
        case R.id.user_select_done_menu_btn:
            doneSelectingUsers();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码25 项目: openvidonn   文件: SettingsActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        // TODO: If Settings has multiple levels, Up should navigate up
        // that hierarchy.
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码26 项目: LocationPrivacy   文件: MainActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            return true;
        case R.id.about:
            Intent intent = new Intent(this, AboutActivity.class);
            startActivity(intent);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
源代码27 项目: Curve-Fit   文件: SecondExampleActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        // Respond to the action bar's Up/Home button
        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码28 项目: io2015-codelabs   文件: DetailFragment.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // Some small additions to handle "up" navigation correctly
            Intent upIntent = NavUtils.getParentActivityIntent(getActivity());
            upIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);

            // Check if up activity needs to be created (usually when
            // detail screen is opened from a notification or from the
            // Wearable app
            if (NavUtils.shouldUpRecreateTask(getActivity(), upIntent)
                    || getActivity().isTaskRoot()) {

                // Synthesize parent stack
                TaskStackBuilder.create(getActivity())
                        .addNextIntentWithParentStack(upIntent)
                        .startActivities();
            }

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                // On Lollipop+ we finish so to run the nice animation
                getActivity().finishAfterTransition();
                return true;
            }

            // Otherwise let the system handle navigating "up"
            return false;
        case R.id.map:
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(Constants.MAPS_INTENT_URI +
                    Uri.encode(mAttraction.name + ", " + mAttraction.city)));
            startActivity(intent);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码29 项目: your-local-weather   文件: GraphsActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_refresh:
            if (forecastType.isChecked()) {
                updateLongWeatherForecastFromNetwork("GRAPHS");
            } else {
                updateWeatherForecastFromNetwork("GRAPHS");
            }
            return true;
        case R.id.action_toggle_values:
            toggleValues();
            return true;
        case R.id.action_toggle_yaxis:
            toggleYAxis();
            return true;
        case R.id.action_visible_graphs_settings:
            showSettings();
            return true;
        case R.id.action_graph_combined_settings:
            showCombinedGraphSettings();
            return true;
        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码30 项目: SmileEssence   文件: EditExtractionActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_edit_list_add: {
            addNewExtractionWord();
            break;
        }
        case android.R.id.home: {
            NavUtils.navigateUpFromSameTask(this);
            return true;
        }
    }
    return true;
}