List of usage examples for android.content Intent addCategory
public @NonNull Intent addCategory(String category)
From source file:com.github.chenxiaolong.dualbootpatcher.FileUtils.java
private static void setCommonSaveOptions(Intent intent, String mimeType, String defaultName) { intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(mimeType);//from ww w . j a v a2s. co m intent.putExtra(Intent.EXTRA_TITLE, defaultName); }
From source file:at.diamonddogs.util.Utils.java
/** * Brings up the MAIN/LAUNCHER activity and clears the top * * @param context a {@link Context}//from ww w . ja v a2 s. co m */ public static void returnToHome(Context context) { PackageManager pm = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setPackage(context.getPackageName()); List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0); Intent homeIntent = new Intent("android.intent.action.MAIN"); homeIntent.addCategory("android.intent.category.LAUNCHER"); homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); homeIntent.setComponent(new ComponentName(context.getPackageName(), activities.get(0).activityInfo.name)); context.startActivity(homeIntent); }
From source file:com.activiti.android.platform.provider.transfer.ContentTransferManager.java
public static final void requestGetContentFromProvider(Fragment fr) { String tmpMimetype = "*/*"; if (AndroidVersion.isKitKatOrAbove()) { isMediaProviderSupported(fr.getActivity()); Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(tmpMimetype);/*from ww w . ja v a 2 s.com*/ fr.startActivityForResult(intent, PICKER_REQUEST_CODE); } }
From source file:com.activiti.android.platform.provider.transfer.ContentTransferManager.java
public static final void requestCreateLocalContent(Fragment fr, String filename, String mimetype, File file) { if (AndroidVersion.isKitKatOrAbove()) { Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(mimetype);/*w w w . ja va 2 s . c o m*/ intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); intent.putExtra(Intent.EXTRA_TITLE, filename); fr.startActivityForResult(intent, CREATE_REQUEST_CODE); } else { // Good question ? Send Intent ? File Picker ? } }
From source file:com.activiti.android.platform.provider.transfer.ContentTransferManager.java
public static final void requestGetContent(Fragment fr, String mimetype) { String tmpMimetype = mimetype; if (TextUtils.isEmpty(mimetype)) { tmpMimetype = "*/*"; }//from w w w.j a v a2s .c o m if (AndroidVersion.isKitKatOrAbove()) { isMediaProviderSupported(fr.getActivity()); Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(tmpMimetype); fr.startActivityForResult(Intent.createChooser(intent, "chooser"), PICKER_REQUEST_CODE); } else { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(tmpMimetype); fr.startActivityForResult(intent, PICKER_REQUEST_CODE); } }
From source file:cn.whereyougo.framework.utils.PackageManagerUtil.java
/** * ????/*from ww w . j a va 2s . com*/ * * @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);// ?? }
From source file:com.krayzk9s.imgurholo.tools.ImageUtils.java
public static void gotoUser(android.support.v4.app.Fragment fragment, JSONParcelable imageData) { try {//from www .jav a 2 s . c om Intent intent = new Intent(); intent.putExtra("username", imageData.getJSONObject().getString("account_url")); intent.setAction(ImgurHoloActivity.ACCOUNT_INTENT); intent.addCategory(Intent.CATEGORY_DEFAULT); fragment.startActivity(intent); } catch (JSONException e) { Log.e("Error!", e.toString()); } }
From source file:mobisocial.socialkit.musubi.Musubi.java
public static boolean isMusubiInstalled(Context context) { try {//from w w w .java 2 s .c o m final Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setPackage(SUPER_APP_ID); return context.getPackageManager().queryIntentActivities(intent, 0).size() > 0; } catch (Throwable t) { return false; } }
From source file:com.airbop.client.GCMIntentService.java
private static void generateNotification(Context context, String title, String message, String url, String large_icon) {//from w w w . ja v a 2 s. c o m int icon = R.drawable.ic_stat_gcm; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if ((title == null) || (title.equals(""))) { title = context.getString(R.string.app_name); } Intent notificationIntent = null; if ((url == null) || (url.equals(""))) { //just bring up the app notificationIntent = new Intent(context, DemoActivity.class); } else { //Launch the URL notificationIntent = new Intent(Intent.ACTION_VIEW); notificationIntent.setData(Uri.parse(url)); notificationIntent.addCategory(Intent.CATEGORY_BROWSABLE); } // 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 notification = new NotificationCompat.Builder(context).setContentTitle(title) .setContentText(message).setContentIntent(intent).setSmallIcon(icon) .setLargeIcon(decodeImage(large_icon)).setWhen(when) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)).build(); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }
From source file:com.asksven.betterbatterystats.PackageFragmentActivity.java
public static void showAppOps(Context context, String packageName) { Intent intent = null; // JB//ww w. j a v a 2s . c o m if (Build.VERSION.SDK_INT == 18) { intent = new Intent("android.settings.APP_OPS_SETTINGS"); Uri uri = Uri.fromParts(SCHEME, packageName, null); } else if (Build.VERSION.SDK_INT >= 19) { // @see http://brightechno.com/blog/archives/211 intent = new Intent(); intent.setClassName("com.android.settings", "com.android.settings.Settings"); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); intent.putExtra(":android:show_fragment", "com.android.settings.applications.AppOpsSummary"); } if (intent != null) { try { context.startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(context, context.getString(R.string.message_no_appops), Toast.LENGTH_SHORT).show(); } } }