List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TOP
int FLAG_ACTIVITY_CLEAR_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.
Click Source Link
From source file:Main.java
public static <T extends Activity> void startActivity(Activity parent, Class<T> clazz, boolean killParent) { Intent intent = new Intent(parent, clazz); if (killParent) { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); }//w ww .ja v a 2 s . c o m parent.startActivity(intent); if (killParent) { parent.finish(); } }
From source file:Main.java
public static <T extends Activity> void startActivity(Activity parent, Class<T> clazz, boolean killParent) { Intent intent = new Intent(parent, clazz); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); parent.startActivity(intent);// w w w. j a va2 s . c o m if (killParent) { parent.finish(); } }
From source file:Main.java
private static Intent createCalendarIntent(String action) { Intent intent = new Intent(); intent.setAction(action);//from ww w. ja v a 2 s .c o m intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); return intent; }
From source file:Main.java
public static void startActivityNoHistory(Activity activity, Class classActivity) { Intent intent = new Intent(); intent.setClass(activity, classActivity); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); activity.startActivity(intent);// w w w .j av a 2s.co m }
From source file:Main.java
public static void restartApp(Activity activity) { if (activity == null) { return;//from ww w. ja va 2 s. co m } Intent i = activity.getBaseContext().getPackageManager() .getLaunchIntentForPackage(activity.getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); activity.startActivity(i); activity.finish(); }
From source file:Main.java
/** * Restart the app.//from www . j av a2 s . c o m * @param context */ public static void restartApplication(Context context) { Intent i = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent p = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 500, p); //kill the application System.exit(0); }
From source file:Main.java
public static void openApplication(final Context context, String packageName) { PackageManager packageManager = context.getPackageManager(); Intent intent = packageManager.getLaunchIntentForPackage(packageName); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(intent);/* www.j a v a 2s . c o m*/ }
From source file:Main.java
/** * Goes back to the specific activity if it was already created and clears stack * on top of it// ww w .ja v a 2 s.co m * @param context context to work in * @param activityToGoBack activity class to go back to */ public static void goBackTo(Context context, Class<? extends Activity> activityToGoBack) { Intent intent = new Intent(context, activityToGoBack); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); context.startActivity(intent); }
From source file:Main.java
public static void standardUp(Activity activity) { Intent upIntent = NavUtils.getParentActivityIntent(activity); if (NavUtils.shouldUpRecreateTask(activity, upIntent)) { TaskStackBuilder.create(activity).addNextIntentWithParentStack(upIntent).startActivities(); } else {/*from www . ja v a 2 s . co m*/ upIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); activity.startActivity(upIntent); activity.finish(); } }
From source file:Main.java
public static boolean startActivityUsingScheme(Activity a, String scheme, Bundle args) { Uri uri = Uri.parse(scheme + "://"); Intent intent = new Intent(Intent.ACTION_RUN, uri); boolean result = true; try {//from w w w .jav a 2s. c om intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (args != null) intent.putExtras(args); a.startActivity(intent); } catch (Exception e) { Log.e(a.getClass().getName(), e.getMessage(), e); result = false; } return result; }