List of usage examples for android.content Intent addFlags
public @NonNull Intent addFlags(@Flags int flags)
From source file:com.krayzk9s.imgurholo.tools.ImageUtils.java
public static void shareImage(Fragment fragment, JSONParcelable imageData) { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); try {// w ww. j a v a 2 s . c o m intent.putExtra(Intent.EXTRA_TEXT, imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK)); } catch (JSONException e) { Log.e("Error!", "bad link to share"); } fragment.startActivity(intent); }
From source file:com.userhook.UserHook.java
private static void startActivityToRate() { Uri uri = Uri.parse("market://details?id=" + applicationContext.getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); if (goToMarket.resolveActivity(applicationContext.getPackageManager()) != null) { activityLifecycle.getCurrentActivity().startActivity(goToMarket); return;// ww w .j a va2 s.co m } activityLifecycle.getCurrentActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + applicationContext.getPackageName()))); }
From source file:com.partner.common.updater.ApkDownloadUtil.java
public static void installBundledApps(File file) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PartnerApplication.getInstance().startActivity(intent); }
From source file:com.stroke.academy.common.updater.ApkDownloadUtil.java
public static void installBundledApps(File file) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); AcademyApplication.getInstance().startActivity(intent); }
From source file:com.bt.download.android.gui.util.UIUtils.java
/** * Checks setting to show or not the transfers window right after a download has started. * This should probably be moved elsewhere (similar to GUIMediator on the desktop) * @param activity//from ww w.j a va 2s . co m */ public static void showTransfersOnDownloadStart(Context context) { if (ConfigurationManager.instance().showTransfersOnDownloadStart() && context != null) { Intent i = new Intent(context, MainActivity.class); i.setAction(Constants.ACTION_SHOW_TRANSFERS); i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); context.startActivity(i); } }
From source file:me.gpelaez.cordova.plugins.ibeacon.GPIBeacon.java
/** * + * Issues a notification to inform the user that server has sent a * message. +//from ww w .j ava 2 s. c o m * @throws JSONException */ @SuppressLint("InlinedApi") private static void createNotification(Context context, JSONObject json) throws JSONException { Bundle extra = new Bundle(); extra.putString("json", json.toString()); Intent notificationIntent = new Intent(activity, BeaconNotificationHandler.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); notificationIntent.putExtra("beacon", extra); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setDefaults(Notification.DEFAULT_ALL).setSmallIcon(context.getApplicationInfo().icon) .setWhen(System.currentTimeMillis()).setTicker(json.getString("title")) .setContentTitle(json.getString("message")).setContentIntent(contentIntent); String message = json.getString("message"); if (message != null) { mBuilder.setContentText(message); } else { mBuilder.setContentText("<missing message content>"); } mBuilder.addAction(context.getApplicationInfo().icon, json.getString("message"), contentIntent); ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)) .notify((String) getAppName(context), NOTIFICATION_ID, mBuilder.build()); }
From source file:com.frostwire.android.gui.util.UIUtils.java
public static void goToFrostWireMainActivity(Activity activity) { final Intent intent = new Intent(activity, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); activity.startActivity(intent);/*from w w w .java 2 s . co m*/ activity.finish(); activity.overridePendingTransition(0, 0); }
From source file:org.zywx.wbpalmstar.engine.EUtil.java
public static void installApp(Context context, String inAppPath) { if (null == inAppPath || 0 == inAppPath.trim().length()) { return;//from w w w.j a v a2 s . c om } String reallyPath = ""; File file = new File(inAppPath); if (file.exists()) { reallyPath = inAppPath; } else { reallyPath = copyFileToStorage(context, inAppPath); if (null == reallyPath) { return; } } // install apk. Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); MimeTypeMap type = MimeTypeMap.getSingleton(); String mime = type.getMimeTypeFromExtension("apk"); reallyPath = reallyPath.contains("file://") ? reallyPath : ("file://" + reallyPath); intent.setDataAndType(Uri.parse(reallyPath), mime); context.startActivity(intent); }
From source file:com.otaupdater.utils.Utils.java
public static void showProKeyOnlyFeatureDialog(final Context ctx, final DialogCallback callback) { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle(R.string.prokey_only_feature_title); builder.setMessage(R.string.prokey_only_feature_message); builder.setPositiveButton(R.string.prokey_only_get, new DialogInterface.OnClickListener() { @Override//ww w . j a v a 2 s .c o m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent i = new Intent(ctx, SettingsActivity.class); i.setAction(SettingsActivity.EXTRA_SHOW_GET_PROKEY_DLG); i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); ctx.startActivity(i); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { if (callback != null) callback.onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (callback != null) callback.onDialogClosed(dlg); } }); dlg.show(); }
From source file:cn.whereyougo.framework.utils.PackageManagerUtil.java
/** * ????//w w w .j a va 2 s . c o m * * @param mContext * * @param TagClass * ??? * @param iconResId * ?? * @param iconName * ?? */ public static void addShortCut2Desktop(Context mContext, Class<?> TagClass, int iconResId, String iconName) { SharedPreferences sp = mContext.getSharedPreferences("appinfo", Context.MODE_PRIVATE); if (!sp.getBoolean("shortcut_flag_icon", false)) { sp.edit().putBoolean("shortcut_flag_icon", true).commit(); LogUtil.d("shortcut", "first create successfull"); } else { LogUtil.d("shortcut", "no created"); return; } String ACTION_ADD_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT"; Intent intent = new Intent(); intent.setClass(mContext, TagClass); intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); Intent addShortcut = new Intent(ACTION_ADD_SHORTCUT); Parcelable icon = Intent.ShortcutIconResource.fromContext(mContext, iconResId);// ??? addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, iconName);// ?? addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);// ?? addShortcut.putExtra("duplicate", false);// ???? addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);// ?? mContext.sendBroadcast(addShortcut);// ?? }