List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
From source file:Main.java
public static void sendStringByMail(Context c, String string) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "DROIDSHEEP DEBUG INFORMATION"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, string); c.startActivity(Intent.createChooser(emailIntent, "Send mail...")); }
From source file:Main.java
/** * Share App//from ww w . ja va 2s . c o m * * @param context */ public static void shareApp(Context context) { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); String title = "Share NavigationFastFrame"; String extraText = "NavigationFastFrame is a very good Frame."; intent.putExtra(Intent.EXTRA_TEXT, extraText); //Share text. intent.putExtra(Intent.EXTRA_SUBJECT, title); context.startActivity(Intent.createChooser(intent, "Share this")); }
From source file:Main.java
public static Intent newCalendarIntent(Context context, Date startDate, String title, String location, String note) {//from w w w .ja v a 2s.co m Calendar cal = Calendar.getInstance(); cal.setTime(startDate); Intent intent = new Intent(Intent.ACTION_EDIT); intent.setType("vnd.android.cursor.item/event"); intent.putExtra("beginTime", cal.getTimeInMillis()); intent.putExtra("endTime", cal.getTimeInMillis() + 60 * 60 * 1000); intent.putExtra("allDay", true); //intent.putExtra("rrule", "FREQ=WEEKLY;COUNT="+numWeeks); //intent.putExtra("rrule", "FREQ=YEARLY"); intent.putExtra("title", title); intent.putExtra("eventLocation", location); intent.putExtra("description", note); //intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE); //intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY); return intent; }
From source file:Main.java
public static Intent openFile(Uri uri, String mimeType) { final Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.setType(mimeType); return intent; }
From source file:Main.java
public static Intent share(String text, String mimeType, Uri... attachments) { final Intent intent = new Intent(); intent.setType(mimeType); if (attachments.length > 1) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); final ArrayList<CharSequence> textExtra = new ArrayList<>(); textExtra.add(text);//from ww w . ja v a 2s . c om intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, textExtra); final ArrayList<Parcelable> uris = new ArrayList<>(); Collections.addAll(uris, attachments); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } else { intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_STREAM, attachments[0]); } return intent; }
From source file:Main.java
public static Intent share(String text, String mimeType, Uri... attachments) { final Intent intent = new Intent(); intent.setType(mimeType); if (attachments.length > 1) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); final ArrayList<CharSequence> textExtra = new ArrayList<>(); textExtra.add(text);/*from w w w . j av a 2s . c o m*/ intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, textExtra); final ArrayList<Parcelable> uris = new ArrayList<>(); Collections.addAll(uris, attachments); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } else { intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, text); if (attachments.length > 0) { intent.putExtra(Intent.EXTRA_STREAM, attachments[0]); } } return intent; }
From source file:Main.java
public static Intent getSMSIntent(String body) { Intent it = new Intent(Intent.ACTION_VIEW); it.putExtra("sms_body", body); it.setType("vnd.android-dir/mms-sms"); return it;//from w w w. j a v a 2s .c om }
From source file:Main.java
public static void sendMessageText(Activity activity, String text) { Intent it = new Intent(Intent.ACTION_VIEW); it.putExtra("sms_body", text); it.setType("vnd.android-dir/mms-sms"); activity.startActivity(it);/*from w w w .j av a2s . c o m*/ }
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); intent.putExtra(Intent.EXTRA_TEXT, body); if (attachments != null && !attachments.isEmpty()) { intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(attachments)); }/*from w w w .j a v a 2 s.c o m*/ return intent; }
From source file:Main.java
public static void sendEmail(Context context, String chooserTitle, String mailAddress, String subject, String preContent) {/* ww w . ja v a2s . co m*/ final Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { mailAddress }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); String content = "\n\n=====================\n"; content += "Device Environment: \n----\n" + preContent; emailIntent.putExtra(Intent.EXTRA_TEXT, content); context.startActivity(Intent.createChooser(emailIntent, chooserTitle)); }