List of usage examples for android.content Intent setFlags
public @NonNull Intent setFlags(@Flags int flags)
From source file:Main.java
public static void bindOnClick(final Activity context, int viewId, final Class<?> clazz, final int flags) { View view = (View) context.findViewById(viewId); view.setOnClickListener(new View.OnClickListener() { @Override/*ww w. j av a2s. c o m*/ public void onClick(View v) { Intent intent = new Intent(context, clazz); if (flags > 0) { intent.setFlags(flags); } 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);//from www.j a va 2 s . c om }
From source file:Main.java
/** * Open Calendar app with specific time//w w w. java 2 s. c o m */ public static void openCalendar(Activity activity, long epochEventStartTime) { Uri uri = Uri.parse("content://com.android.calendar/time/" + epochEventStartTime); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); intent.putExtra("VIEW", "DAY"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); activity.startActivity(intent); }
From source file:Main.java
public static Intent getShareTextIntent(String content) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, content); return intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); }
From source file:Main.java
public static void takeMyselfToForeground(Context context, Class launcher) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClass(context, launcher);/*from w ww . j a v a 2 s .co m*/ intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); context.startActivity(intent); }
From source file:Main.java
public static Intent createLaunchIntent(ComponentName componentName) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(componentName);// w ww .j ava 2 s . c om intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); return intent; }
From source file:Main.java
public static void installApk(Context context, File apkFile) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);// w ww .j ava 2 s. c o m }
From source file:com.manning.androidhacks.hack046.helper.NotificationHelper.java
private static PendingIntent getDeletePendingIntent(Context ctx) { Intent intent = new Intent(ctx, MsgService.class); intent.setAction(MsgService.MSG_DELETE); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); return PendingIntent.getService(ctx, 0, intent, 0); }
From source file:Main.java
public static void install(Context context, File uriFile) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(uriFile), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);//from w w w. java 2 s. co m }
From source file:Main.java
/** * start app/* w ww. jav a 2s. c o m*/ * * @param ctx * @param packageName */ public static void startApp(Context ctx, String packageName) { if (!isAppInstalled(ctx, packageName)) { return; } PackageManager packageManager = ctx.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); ctx.startActivity(intent); }