Example usage for android.support.v4.app NavUtils navigateUpTo

List of usage examples for android.support.v4.app NavUtils navigateUpTo

Introduction

In this page you can find the example usage for android.support.v4.app NavUtils navigateUpTo.

Prototype

public static void navigateUpTo(Activity sourceActivity, Intent upIntent) 

Source Link

Document

Navigate from sourceActivity to the activity specified by upIntent, finishing sourceActivity in the process.

Usage

From source file:com.dgsd.android.ShiftTracker.StApp.java

public static void doDefaultNavigateUp(Activity a) {
    Intent upIntent = new Intent(a, StApp.getHomeClass(a));
    if (NavUtils.shouldUpRecreateTask(a, upIntent)) {
        TaskStackBuilder.create(a).addNextIntent(upIntent).startActivities();
        a.finish();/*from  www  . j  av  a  2s .co  m*/
    } else {
        NavUtils.navigateUpTo(a, upIntent);
    }
}

From source file:se.trixon.confqual.QualifierDetailActivity.java

@Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        NavUtils.navigateUpTo(this, new Intent(this, QualifierListActivity.class));
    } else if (item.getItemId() == R.id.menu_about) {
        ((ConfQualApplication) getApplication()).getAboutDialog(this).show();
    }// www  .  j a  v  a  2  s .  c  o m

    return super.onOptionsItemSelected(item);
}

From source file:com.blipsqueak.app.BaseActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        Intent upIntent = NavUtils.getParentActivityIntent(this);
        NavUtils.navigateUpTo(this, upIntent);
        overridePendingTransition(R.anim.exit_in, R.anim.exit_out);
        return true;
    }//from   ww w. j ava2  s. c  o  m
    return super.onOptionsItemSelected(item);
}

From source file:com.microsoft.graph.snippets.SnippetDetailActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        NavUtils.navigateUpTo(this, new Intent(this, SnippetListActivity.class));
        return true;
    }/* w  w w  .j a  va  2 s  . c  o  m*/
    return super.onOptionsItemSelected(item);
}

From source file:net.v00d00.xr.SettingsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        Intent upIntent = new Intent(this, HomeActivity.class);
        NavUtils.navigateUpTo(this, upIntent);
        return true;
    }//  w  w  w . j a va 2  s .c  o  m
    return super.onOptionsItemSelected(item);
}

From source file:com.viberlabs.app.smartreminder.LicensesActivity.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 add_reminder, see the Navigation pattern on Android Design:
        ////from w  w w .ja  v a  2  s  .  c o  m
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        NavUtils.navigateUpTo(this, new Intent(this, ReminderListMainActivity.class));
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.krbguide.kebunrayabogorguide.HelpActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        NavUtils.navigateUpTo(this, new Intent(this, MapsActivity.class));
        return true;
    }//from  w  ww .  ja  v a  2 s.com
    return super.onOptionsItemSelected(item);
}

From source file:org.iteventviewer.app.BaseActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case android.R.id.home:
        Intent intent = upIntent();/*ww w  .  j  a  v  a2s.com*/
        if (intent != null) {
            NavUtils.navigateUpTo(this, intent);
            return true;
        }
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.dabay6.libraries.androidshared.util.NavigationUtils.java

/**
 * Navigate back up the back stack.//w w w .  j  a v a  2  s .c om
 *
 * @param activity The current {@link Activity}.
 */
public static void navigateUp(final Activity activity) {
    // This is called when the Home (Up) button is pressed in the action bar. Create a simple intent that starts the
    // hierarchical parent activity and use NavUtils in the Support Package to ensure proper handling of Up.
    final Intent upIntent = NavUtils.getParentActivityIntent(activity);

    if (NavUtils.shouldUpRecreateTask(activity, upIntent)) {
        // This activity is not part of the application's task, so create a new task with a synthesized back stack.
        TaskStackBuilder.create(activity)
                // If there are ancestor activities, they should be added here.
                .addNextIntent(upIntent).startActivities();
        activity.finish();
    } else {
        // This activity is part of the application's task, so simply navigate up to the hierarchical parent
        // activity.
        NavUtils.navigateUpTo(activity, upIntent);
    }
}

From source file:com.richtodd.android.quiltdesign.app.FileSelectActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int itemId = item.getItemId();
    switch (itemId) {
    case android.R.id.home: {
        Intent upIntent = NavUtils.getParentActivityIntent(this);
        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();// www  .  ja  v a2  s . c  om
        } else {
            // This activity is part of this app's task, so simply
            // navigate up to the logical parent activity.
            NavUtils.navigateUpTo(this, upIntent);
        }
    }
    }

    return super.onOptionsItemSelected(item);
}