List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
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 w w . j a va 2s . 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:mohammad.adib.oy.OyUtils.java
public static void sendInvite(Context context) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "Oy! Wanna fraandship?\nSend me an Oy: " + ParseUser.getCurrentUser().getUsername().toUpperCase()); sendIntent.setType("text/plain"); context.startActivity(sendIntent);//from w ww. j ava 2 s.c o m }
From source file:at.wada811.utils.IntentUtils.java
/** * Intent???//ww w . jav a 2 s . c om * * @param intent * @param filePaths * @param mimeType * @return */ public static Intent addFiles(Intent intent, ArrayList<String> filePaths, String mimeType) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); intent.setType(mimeType); ArrayList<Uri> uris = new ArrayList<Uri>(filePaths.size()); for (String filePath : filePaths) { uris.add(Uri.fromFile(new File(filePath))); } intent.putExtra(Intent.EXTRA_STREAM, uris); return intent; }
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.j ava2 s. c o m*/ * @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:Main.java
public static boolean sendMail(Context context, String destination, String subject, String body) { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); String aEmailList[] = { destination }; emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList); if (subject != null) { emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); }//www . ja va 2s .c om if (body != null) { emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body); } emailIntent.setType("plain/text"); boolean ret = true; try { context.startActivity(emailIntent); } catch (Exception e) { ret = false; } return ret; }
From source file:com.phunkosis.gifstitch.helpers.ShareHelper.java
public static void startShareLinkIntent(Activity activity, String url) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, activity.getResources().getString(R.string.share_link_body) + " " + url); intent.putExtra(Intent.EXTRA_SUBJECT, activity.getResources().getString(R.string.share_link_subject)); intent.setType("text/plain"); activity.startActivity(Intent.createChooser(intent, "Share ")); }
From source file:com.manning.androidhacks.hack036.util.LaunchEmailUtil.java
public static void launchEmailToIntent(Context context) { Intent msg = new Intent(Intent.ACTION_SEND); StringBuilder body = new StringBuilder("\n\n----------\n"); body.append(EnvironmentInfoUtil.getApplicationInfo(context)); msg.putExtra(Intent.EXTRA_EMAIL, context.getString(R.string.mail_support_feedback_to).split(", ")); msg.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.mail_support_feedback_subject)); msg.putExtra(Intent.EXTRA_TEXT, body.toString()); msg.setType("message/rfc822"); context.startActivity(Intent.createChooser(msg, context.getString(R.string.pref_sendemail_title))); }
From source file:com.github.chenxiaolong.dualbootpatcher.FileUtils.java
private static void setCommonOpenOptions(Intent intent, String mimeType) { intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(mimeType); }
From source file:Main.java
public static Intent getAddToContactIntent(CharSequence name, CharSequence phoneNumber, int phoneNumberType) { Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT); intent.putExtra(Intents.Insert.PHONE, phoneNumber); // Only include the name and phone type extras if they are specified (the method // getAddNumberToContactIntent does not use them). if (name != null) { intent.putExtra(Intents.Insert.NAME, name); }//from w w w. ja va 2s . c o m if (phoneNumberType != -1) { intent.putExtra(Intents.Insert.PHONE_TYPE, phoneNumberType); } intent.setType(Contacts.CONTENT_ITEM_TYPE); return intent; }
From source file:Main.java
public static Intent getIntentForAction(int action) { Log.d(TAG, "[AirImagePickerUtils] Entering getIntentForAction"); Intent intent; switch (action) { case GALLERY_IMAGES_ONLY_ACTION: intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return intent; case GALLERY_VIDEOS_ONLY_ACTION: intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("video/*"); Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return intent; case CAMERA_IMAGE_ACTION: Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return new Intent(MediaStore.ACTION_IMAGE_CAPTURE); case CAMERA_VIDEO_ACTION: Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return new Intent(MediaStore.ACTION_VIDEO_CAPTURE); case CROP_ACTION: Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return new Intent("com.android.camera.action.CROP"); default:/*ww w . j a v a2 s . co m*/ Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return null; } }