Example usage for android.content Intent FLAG_ACTIVITY_CLEAR_TOP

List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TOP

Introduction

In this page you can find the example usage for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.

Prototype

int FLAG_ACTIVITY_CLEAR_TOP

To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.

Click Source Link

Document

If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

Usage

From source file:Main.java

public static void goHome(Activity parent) {
    Intent i = new Intent(parent, Main.class);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP + Intent.FLAG_ACTIVITY_NEW_TASK);
    parent.startActivity(i);/* w  w  w .j  ava2s .co m*/
}

From source file:Main.java

public static void startMainActivity(Context context) {
    Intent intent = new Intent("MAIN_ACTIVITY");
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(intent);//from   w w w  .j a v  a 2 s.co  m
}

From source file:Main.java

public static Intent getHomeIntent() {
    final Intent intent = new Intent("com.announcify");
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    return intent;
}

From source file:Main.java

public static void startActivityAndClear(Context act, Class<?> cls) {
    Intent intent = new Intent(act, cls);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    act.startActivity(intent);//from   ww  w . j  a  v a2  s . c om
}

From source file:Main.java

public static Intent getIntent(Context context, Class clazz) {
    final Intent intent = new Intent(context, clazz);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);

    return intent;
}

From source file:Main.java

public static void CloseActivity(Activity activity, Class<?> class1) {
    Intent intent = new Intent(activity, class1);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    activity.startActivity(intent);/*  www .  j a  v  a  2s .  c  om*/
}

From source file:Main.java

public static void redirectWithClearTop(Activity activity, Class<?> cls) {
    Intent intent = new Intent(activity, cls);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    activity.startActivity(intent);/*from w w  w.  ja  v a  2  s  . co  m*/
    activity.overridePendingTransition(0, 0);
}

From source file:Main.java

private static Intent getNewStandardIntent(Context packageContext, Class<?> cls) {
    Intent intent = new Intent(packageContext, cls);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    return intent;
}

From source file:Main.java

public static Intent getVideoFileIntent(String param) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("oneshot", 0);
    intent.putExtra("configchange", 0);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "video/*");
    return intent;
}

From source file:Main.java

public static Intent getAudioFileIntent(String param) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("oneshot", 0);
    intent.putExtra("configchange", 0);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "audio/*");
    return intent;
}