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

private static Intent getAudioFileIntent(File file) {
    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(file);//from   w ww .  java  2s .  com
    intent.setDataAndType(uri, "audio/*");
    return intent;
}

From source file:Main.java

public static void restartApp(Context context) {
    Intent i = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(i);// w  w w . j av  a2  s  .co  m
}

From source file:Main.java

private static Intent getVideoFileIntent(File file) {
    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(file);/*ww  w .  jav a  2 s.c  o  m*/
    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;
}

From source file:Main.java

public static void sair(Intent intent, Context context) {
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(intent);/*from  www.j  av a  2s.  com*/
}

From source file:Main.java

private static Intent getVideoFileIntent(String filePath) {

    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(filePath));
    intent.setDataAndType(uri, "video/*");
    return intent;
}

From source file:Main.java

public static void startActivity(Activity callingActivity, Class<?> targetActivity) {
    Intent intent = new Intent(callingActivity, targetActivity);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    callingActivity.startActivity(intent);
}

From source file:Main.java

public static void startActivity(Context context, Class<?> c, boolean clearStack) {
    Intent intent = new Intent(context, c);
    if (clearStack)
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(intent);/* w  w w . ja  va 2s  . c  o m*/
}

From source file:Main.java

public static void putData(Context context, Class<?> activity, String key, String value) {
    Intent intent = new Intent();
    intent.setClass(context, activity);/*from   w  w  w.j  av a 2  s.  com*/
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.putExtra(key, value);
    context.startActivity(intent);
}

From source file:Main.java

public static void startIntentWithoutHistory(Activity activity, Class intentClass) {
    Intent intent = new Intent(activity, intentClass);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);// w  w  w  .j a va2  s  . co  m
}