Move to next Activity With Clear Top Flag - Android Activity

Android examples for Activity:Top Activity

Description

Move to next Activity With Clear Top Flag

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class Main {

    public static void nextWithClearTopFlag(Activity curActivity,
            Class<?> nextActivity) {
        nextWithClearTopFlag(curActivity, nextActivity, null);
    }//  w  w w.j  a va2s  .c o  m

    public static void nextWithClearTopFlag(Activity curActivity,
            Class<?> nextActivity, Bundle extras) {
        Intent intent = new Intent(curActivity, nextActivity);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        if (null != extras) {
            intent.putExtras(extras);
        }
        curActivity.startActivity(intent);
    }
}

Related Tutorials