List of usage examples for android.support.v4.app NavUtils getParentActivityIntent
public static Intent getParentActivityIntent(Activity sourceActivity)
From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.video.SignSearchVideoActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Log.d(TAG, "onOptionsItemSelected() " + this.hashCode()); switch (item.getItemId()) { case android.R.id.home: final Intent upIntent = NavUtils.getParentActivityIntent(this); upIntent.putExtra(SearchManager.QUERY, this.originalQuery); NavUtils.navigateUpTo(this, upIntent); return true; }// www . ja v a2s. c om return super.onOptionsItemSelected(item); }
From source file:com.aetoslabs.quickfacts.AppCompatPreferenceActivity.java
@Nullable public Intent getSupportParentActivityIntent() { return NavUtils.getParentActivityIntent(this); }
From source file:net.olejon.mdapp.SubstanceActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: { Intent intent = NavUtils.getParentActivityIntent(this); if (NavUtils.shouldUpRecreateTask(this, intent)) { TaskStackBuilder.create(this).addNextIntentWithParentStack(intent).startActivities(); } else {//w w w . ja v a 2s.c o m NavUtils.navigateUpTo(this, intent); } return true; } case R.id.substance_menu_interactions: { Intent intent = new Intent(mContext, InteractionsActivity.class); intent.putExtra("search", substanceAtcCode.replace("ATC-kode: ", "")); startActivity(intent); return true; } case R.id.substance_menu_atc: { Intent intent = new Intent(mContext, AtcCodesActivity.class); intent.putExtra("code", substanceAtcCode.replace("ATC-kode: ", "")); startActivity(intent); return true; } default: { return super.onOptionsItemSelected(item); } } }
From source file:com.btmura.android.reddit.app.ThingActivity.java
private void handleHome() { Intent upIntent = NavUtils.getParentActivityIntent(this); upIntent.putExtra(BrowserActivity.EXTRA_SUBREDDIT, getSubreddit()); if (NavUtils.shouldUpRecreateTask(this, upIntent)) { TaskStackBuilder.create(this).addNextIntentWithParentStack(upIntent).startActivities(); } else {/*from w ww . j ava 2 s .c o m*/ NavUtils.navigateUpFromSameTask(this); } }
From source file:com.example.android.xyztouristattractions.ui.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(); }/*from w w w.ja va 2 s . c o m*/ 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); }
From source file:ufms.br.com.ufmsapp.activity.DetalhesEventoActivity.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Intent parentIntent = NavUtils.getParentActivityIntent(this); //parentIntent.putExtra("NAV_VALUE", getIntent().getIntExtra("NAV_UP", -1)); parentIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(parentIntent);/*from w ww .j a v a 2s .co m*/ supportFinishAfterTransition(); return true; } return super.onOptionsItemSelected(item); }
From source file:li.barter.AbstractBarterLiActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // To provide Up navigation if (item.getItemId() == android.R.id.home) { Intent upIntent = NavUtils.getParentActivityIntent(this); if (upIntent == null) { NavUtils.navigateUpFromSameTask(this); } else {/*from w w w .j a v a 2s. co m*/ 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; } else { return super.onOptionsItemSelected(item); } }
From source file:com.asburymotors.android.disneysocal.ui.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(); }/* www . j a v a 2 s. c o m*/ 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; } return super.onOptionsItemSelected(item); }
From source file:com.google.android.apps.forscience.whistlepunk.review.UpdateRunFragment.java
private void returnToRunReview() { Intent upIntent = NavUtils.getParentActivityIntent(getActivity()); upIntent.putExtra(RunReviewActivity.EXTRA_FROM_RECORD, false); upIntent.putExtra(RunReviewFragment.ARG_START_LABEL_ID, mRunId); NavUtils.navigateUpTo(getActivity(), upIntent); }
From source file:org.thialfihar.android.apg.ui.UploadKeyActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: { Intent viewIntent = NavUtils.getParentActivityIntent(this); viewIntent.setData(ApgContract.KeyRings.buildGenericKeyRingUri(mDataUri)); NavUtils.navigateUpTo(this, viewIntent); return true; }//from ww w . j a va2 s . c om } return super.onOptionsItemSelected(item); }