List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
From source file:Main.java
public static Intent buildVideoIntent(Context context, Uri uri) { String title = "Choose photo"; //Build galleryIntent Intent galleryIntent = new Intent(Intent.ACTION_PICK); galleryIntent.setType("video/*"); //Create chooser Intent chooser = Intent.createChooser(galleryIntent, title); Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); Intent[] extraIntents = { cameraIntent }; chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents); return chooser; }
From source file:Main.java
public static void pickImageFromAlbum(final Activity activity) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); activity.startActivityForResult(intent, REQUEST_CODE_FROM_ALBUM); }
From source file:Main.java
public static void startEmailIntent(Context context, String emailAddress) { try {/*from ww w.j a v a 2 s .co m*/ Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { emailAddress }); context.startActivity(intent); } catch (Exception ex) { Log.e(TAG, "Error starting email intent.", ex); Toast.makeText(context, "Sorry, we couldn't find any app for sending emails!", Toast.LENGTH_SHORT) .show(); } }
From source file:com.manning.androidhacks.hack004.util.LaunchEmailUtil.java
public static void launchEmailToIntent(Context context) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "feed@back.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, "[50AH] Feedback"); intent.putExtra(Intent.EXTRA_TEXT, "Feedback:\n"); context.startActivity(Intent.createChooser(intent, "Send feedback")); }
From source file:Main.java
public static Intent newSendMultipleAttachmentsIntent(String emailAddress, String subject, String contentBody, ArrayList<Uri> uris) { final Intent ei = new Intent(Intent.ACTION_SEND_MULTIPLE); ei.setType("plain/text"); ei.putExtra(Intent.EXTRA_EMAIL, new String[] { emailAddress }); ei.putExtra(Intent.EXTRA_SUBJECT, subject); //ei.putExtra(Intent.EXTRA_TEXT, contentBody); //fix for ClassCastException with Intent.EXTRA_TEXT : https://code.google.com/p/android/issues/detail?id=38303 //: use list of string not a string ArrayList<String> extra_text = new ArrayList<String>(); extra_text.add(contentBody);/*from w ww .j av a2 s . com*/ ei.putExtra(Intent.EXTRA_TEXT, extra_text); ei.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); return ei; }
From source file:Main.java
@NonNull public static Intent sendEmail(@NonNull String[] to, @NonNull String subject, @NonNull String body, @Nullable List<Uri> attachments) { final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, to); intent.putExtra(Intent.EXTRA_SUBJECT, subject); final ArrayList<CharSequence> extraText = new ArrayList<>(1); extraText.add(body);//from ww w . j ava 2 s . co m intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, extraText); if (attachments != null && !attachments.isEmpty()) { intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(attachments)); } return intent; }
From source file:Main.java
public static void showEmailDialog(final Context context, final String subject) { new AlertDialog.Builder(context).setTitle("Email Us").setMessage( "Please send email with As many details as possible. We will look into it as soon as possible. \n\nPlease DO NOT change subject and email address. Continue to Email?") .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override/*from ww w. ja va 2s .com*/ public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/html"); // intent.putExtra(Intent.EXTRA_EMAIL, R.string.app_email); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, ""); context.startActivity(Intent.createChooser(intent, "Send Email")); } }).setIcon(android.R.drawable.ic_dialog_info).show(); }
From source file:Main.java
public static void FindPhoto(Activity activity) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); activity.startActivityForResult(intent, REQUEST_CODE_FROM_ALBUM); }
From source file:Main.java
/** * Helper method for sharing an image.//from w w w . j a va 2s. c o m * * @param context The image context. * @param imagePath The path of the image to be shared. */ static void shareImage(Context context, String imagePath) { // Create the share intent and start the share activity File imageFile = new File(imagePath); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); Uri photoURI = FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY, imageFile); shareIntent.putExtra(Intent.EXTRA_STREAM, photoURI); context.startActivity(shareIntent); }
From source file:Main.java
public static void ShareApplication(Context mContext) { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intent.EXTRA_SUBJECT, "Search Sri Lanka Railway Time Table"); intent.putExtra(Intent.EXTRA_TITLE, "Search Sri Lanka Railway Time Table"); intent.putExtra(Intent.EXTRA_TEXT,//from w w w.ja v a 2 s . com "Search \"Sri Lanka Railway Time Table\" on your Android. http://market.android.com/details?id=com.aselalee.trainschedule"); mContext.startActivity(Intent.createChooser(intent, "Spread the word")); return; }