List of usage examples for android.content Intent setFlags
public @NonNull Intent setFlags(@Flags int flags)
From source file:im.delight.android.commons.Social.java
/** * Displays an application chooser and shares the specified file using the selected application * * @param context a context reference//from w ww . ja v a 2 s . c om * @param windowTitle the title for the application chooser's window * @param fileToShare the file to be shared * @param mimeTypeForFile the MIME type for the file to be shared (e.g. `image/jpeg`) * @param subjectTextToShare the message title or subject for the file, if supported by the target application */ public static void shareFile(final Context context, final String windowTitle, final File fileToShare, final String mimeTypeForFile, final String subjectTextToShare) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setType(mimeTypeForFile); intent.putExtra(Intent.EXTRA_SUBJECT, subjectTextToShare); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fileToShare)); context.startActivity(Intent.createChooser(intent, windowTitle)); }
From source file:com.vendsy.bartsy.venue.GCMIntentService.java
/** * To generate a notification to inform the user that server has sent a message. * /*from w w w . j ava 2s . co m*/ * @param count * @param count */ private static void generateNotification(Context context, String message, String count) { int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, MainActivity.class); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; try { int countValue = Integer.parseInt(count); notification.number = countValue; } catch (NumberFormatException e) { e.printStackTrace(); } // // Play default notification sound notification.defaults = Notification.DEFAULT_SOUND; notificationManager.notify(0, notification); }
From source file:de.da_sense.moses.client.abstraction.ApkMethods.java
/** * Installs a given APK file.//from www . ja v a 2 s. c o m * * @param apk * the apk file to install * @param baseActivity * the base activity * @throws IOException * if the file does not exist */ public static void installApk(File apk, ExternalApplication appRef, ApkInstallObserver o) throws IOException { MosesService service = MosesService.getInstance(); if (service != null) { if (apk.exists()) { InstallApkActivity.setAppToInstall(apk, appRef, o); Intent installActivityIntent = new Intent(service, InstallApkActivity.class); installActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); service.startActivity(installActivityIntent); } else { o.apkInstallError(apk, appRef, new RuntimeException("Could not install apk file because it was nonexistent.")); } } else { o.apkInstallError(apk, appRef, new RuntimeException("Could not install apk file because the service was not running.")); } }
From source file:com.adguard.android.commons.BrowserUtils.java
public static void startBrowser(Context context, ComponentName component) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(component);/* w w w .ja v a2s. c o m*/ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:com.yutong.axxc.parents.view.common.ActivityUtils.java
/** * activity/*from w w w . j a v a 2 s . co m*/ * @param from ?activity * @param to activity * @param extras ?? */ public static void changeActivity(Activity from, Class<?> to, Bundle extras) { // Intent intent = setIntent(from, to, extras); Intent intent = new Intent(); if (extras != null) intent.putExtras(extras); intent.setClass(from.getBaseContext(), to); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); from.startActivity(intent); //from.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); from.overridePendingTransition(R.anim.enter_righttoleft, R.anim.exit_righttoleft); }
From source file:Main.java
public static void chooserSysPics(Context context, int requestCode) { if (context == null) { return;//from w w w .ja va 2 s . c om } try { Intent localIntent = new Intent(); localIntent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); localIntent.setType("image/*"); // Intent.ACTION_GET_CONTENT localIntent.setAction("android.intent.action.GET_CONTENT"); if (context instanceof Activity) { ((Activity) context).startActivityForResult(localIntent, requestCode); } else { localIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(localIntent); } } catch (Exception e) { } }
From source file:com.teleca.jamendo.activity.HomeActivity.java
/** * Launch Home activity helper//from w w w. ja v a 2 s .c o m * * @param c context where launch home from (used by SplashscreenActivity) */ public static void launch(Context c) { Intent intent = new Intent(c, HomeActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); c.startActivity(intent); }
From source file:com.ruesga.rview.misc.ActivityHelper.java
public static void openChangeListByFilterActivity(Activity activity, String title, ChangeQuery filter, boolean dirty, boolean clearStack) { Intent intent = new Intent(activity, ChangeListByFilterActivity.class); if (clearStack) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); } else {/*from ww w. jav a 2 s .co m*/ intent.putExtra(Constants.EXTRA_HAS_PARENT, true); } intent.putExtra(Constants.EXTRA_TITLE, title); intent.putExtra(Constants.EXTRA_FILTER, filter.toString()); intent.putExtra(Constants.EXTRA_DIRTY, dirty); activity.startActivityForResult(intent, LIST_RESULT_CODE); }
From source file:Main.java
public static void chooserPics(Context context, int requestCode) { if (context == null) { return;/*from ww w . j a v a 2 s . c o m*/ } try { Intent localIntent = new Intent(); localIntent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); localIntent.setType("image/*"); localIntent.setAction(Intent.ACTION_GET_CONTENT); if (context instanceof Activity) { ((Activity) context).startActivityForResult(Intent.createChooser(localIntent, "Select Picture"), requestCode); } else { localIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(Intent.createChooser(localIntent, "Select Picture")); } } catch (Exception e) { } }
From source file:com.frostwire.android.gui.util.UIUtils.java
public static void sendShutdownIntent(Context ctx) { Intent i = new Intent(ctx, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); i.putExtra("shutdown-frostwire", true); ctx.startActivity(i);//from w ww . j a v a 2s . co m }