navigate Up to Activity - Android Activity

Android examples for Activity:Activity Jump

Description

navigate Up to Activity

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Intent;
import android.support.v4.app.NavUtils;
import android.support.v4.app.TaskStackBuilder;

public class Main {
    public static boolean navigateUp(final Activity activity) {
        Intent upIntent = NavUtils.getParentActivityIntent(activity);
        if (NavUtils.shouldUpRecreateTask(activity, upIntent)) {
            TaskStackBuilder.create(activity)
                    .addNextIntentWithParentStack(upIntent)
                    .startActivities();//from w w w . j  av  a2 s. com
        } else {
            NavUtils.navigateUpTo(activity, upIntent);
        }
        return true;
    }
}

Related Tutorials