List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
From source file:Main.java
/** * Get the Intent for selecting content to be used in an Intent Chooser. * /*from w ww.j a va2s . c o m*/ * @return The intent for opening a file with Intent.createChooser() * * @author paulburke */ public static Intent createGetContentIntent() { // Implicitly allow the user to select a particular kind of data final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // The MIME data type filter intent.setType("*/*"); // Only return URIs that can be opened with ContentResolver intent.addCategory(Intent.CATEGORY_OPENABLE); return intent; }
From source file:Main.java
public static List<ResolveInfo> getShareTargets(Context ctx) { Intent intent = new Intent(Intent.ACTION_SEND, null); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setType("text/plain"); PackageManager pm = ctx.getPackageManager(); return pm.queryIntentActivities(intent, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT); }
From source file:Main.java
public static void startSmsIntent(Context context, String phoneNumber) { try {/* w w w.j a v a2s . co m*/ Uri uri = Uri.parse("sms:" + phoneNumber); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.putExtra("address", phoneNumber); intent.setType("vnd.android-dir/mms-sms"); context.startActivity(intent); } catch (Exception ex) { Log.e(TAG, "Error starting sms intent.", ex); Toast.makeText(context, "Sorry, we couldn't find any app to send an SMS!", Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
public static void openAlbum(Activity activity, int requestCode) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); } else {//ww w.j av a2 s .co m intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } activity.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static Boolean isCropAvailable(Activity activity) { Log.d(TAG, "[AirImagePickerUtils] isCropAvailable"); final PackageManager packageManager = activity.getPackageManager(); Intent intent = getIntentForAction(CROP_ACTION); intent.setType("image/*"); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); Log.d(TAG, "[AirImagePickerUtils] Exiting isCropAvailable"); return list.size() > 0; }
From source file:Main.java
public static void startShareIntentActivity(Activity activity, String text) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, text); activity.startActivity(intent);/*from w ww .j av a2s .co m*/ }
From source file:Main.java
/** * Intent chooser is customized to remove unwanted apps. * 1. FaceBook has bug where only links can be shared. * 2. Cannot share this type of content via Google Docs and Skype. *//* www . ja v a 2 s . c o m*/ public static void ShareResult(Context mContext, String mResult, String mTitle) { List<Intent> targetedShareIntents = new ArrayList<Intent>(); Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); List<ResolveInfo> resInfo = mContext.getPackageManager().queryIntentActivities(shareIntent, 0); if (!resInfo.isEmpty()) { for (ResolveInfo resolveInfo : resInfo) { String packageName = resolveInfo.activityInfo.packageName; Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND); targetedShareIntent.setType("text/plain"); targetedShareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mTitle); targetedShareIntent.putExtra(android.content.Intent.EXTRA_TITLE, mTitle); targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, mResult); if (!packageName.toLowerCase().contains("com.facebook.katana") && !packageName.toLowerCase().contains("com.google.android.apps.docs") && !packageName.toLowerCase().contains("com.skype.raider")) { targetedShareIntent.setPackage(packageName); targetedShareIntents.add(targetedShareIntent); } } Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Send your result"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[] {})); mContext.startActivity(chooserIntent); } return; }
From source file:Main.java
private static void shareAct(Activity act, String fileName, String text) { Uri uri = null;// www. j a v a 2 s . c o m try { FileInputStream input = act.openFileInput(fileName); Bitmap bitmap = BitmapFactory.decodeStream(input); uri = Uri.parse(MediaStore.Images.Media.insertImage(act.getContentResolver(), bitmap, null, null)); input.close(); } catch (Exception e) { e.printStackTrace(); } Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/jpeg"); act.startActivity(Intent.createChooser(shareIntent, act.getTitle())); }
From source file:Main.java
public static void shareText(Activity activity, String title, String text) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, text); sendIntent.setType("text/plain"); activity.startActivity(Intent.createChooser(sendIntent, title)); }
From source file:Main.java
public static Intent share(final String content) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, content); sendIntent.setType("text/plain"); return sendIntent; }