List of usage examples for android.content Intent addFlags
public @NonNull Intent addFlags(@Flags int flags)
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); }/*from w ww . ja va 2s .c o m*/ parent.startActivity(intent); if (killParent) { parent.finish(); } }
From source file:Main.java
/** * Restarts activity, from http://stackoverflow.com/questions/1397361/how-do-i-restart-an-android-activity * @param activity the activity to restart *//* w w w . j a v a2 s . c o m*/ @TargetApi(11) public static void restartActivity(Activity activity) { if (Build.VERSION.SDK_INT >= 11) { activity.recreate(); } else { Intent intent = activity.getIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); activity.finish(); activity.overridePendingTransition(0, 0); activity.startActivity(intent); activity.overridePendingTransition(0, 0); } }
From source file:Main.java
/** * Finish the given activity and start a home activity class. * <p>//from w ww . j a va 2 s . c o m * This mirror the behavior of the home action bar button that clears the * current activity and starts or brings another activity to the top. * * @param activity * @param homeActivityClass */ public static void goHome(Activity activity, Class<?> homeActivityClass) { activity.finish(); Intent intent = new Intent(activity, homeActivityClass); intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP); activity.startActivity(intent); }
From source file:Main.java
public static Intent getDialIntent(String phoneNumber) { Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); }
From source file:Main.java
/** * Activity Not Finish Jump//from w ww .ja v a 2 s . c o m */ public static void gotoActivityNotFinishWithExtras(Context context, Class<?> actClass, Bundle bundle) { Intent intent = new Intent(context, actClass); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:Main.java
public static void openWeb(Context context, String url) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url));// w ww .j a va 2 s . c om intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:Main.java
public static void shareText(Context context, String title, String subject, String text, String mime) { Intent share = new Intent(Intent.ACTION_SEND); share.setType(mime);/*from w ww . j a va 2 s . co m*/ share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_DOCUMENT); // Add data to the intent, the receiving app will decide // what to do with it. share.putExtra(Intent.EXTRA_SUBJECT, subject); share.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(Intent.createChooser(share, title)); }
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);/*from w ww .j a v a2 s .c om*/ }
From source file:Main.java
/** * <pre>//from w ww.ja v a2 s . c o m * Start other app by its package name. * </pre> * @param packageName app 's package name */ public static void openApp(String packageName) { Context context = getCurrentContext(); PackageManager manager = context.getPackageManager(); Intent intent = manager.getLaunchIntentForPackage(packageName); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_LAUNCHER); context.startActivity(intent); }
From source file:Main.java
public static String unInstallBySys(Context context, String pckName) { Intent intent = new Intent(); Uri uri = Uri.parse("package:" + pckName); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Intent.ACTION_DELETE); intent.setData(uri);//from w w w.j a v a 2s . com context.startActivity(intent); return null; }