List of usage examples for android.content Intent EXTRA_TEXT
String EXTRA_TEXT
To view the source code for android.content Intent EXTRA_TEXT.
Click Source Link
From source file:Main.java
public static void sendMail(Context context, String dstAddr, String subject, String text) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); String[] address = { dstAddr }; emailIntent.putExtra(Intent.EXTRA_EMAIL, address); emailIntent.setType("message/rfc822"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(Intent.createChooser(emailIntent, "Send mail...")); }
From source file:Main.java
public static void shareFile(Context context, String title, String subject, String text, String mime, String path) {/* w w w. j av a 2s . c o m*/ Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType(mime); sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + path)); sendIntent.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(Intent.createChooser(sendIntent, title)); }
From source file:Main.java
public static void shareText(Context context, String title, String subject, String text, String mime) { Intent share = new Intent(Intent.ACTION_SEND); share.setType(mime);//from www . j a va 2 s. c o m share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_DOCUMENT); // Add data to the intent, the receiving app will decide // what to do with it. share.putExtra(Intent.EXTRA_SUBJECT, subject); share.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(Intent.createChooser(share, title)); }
From source file:Main.java
public static void feedback(Context context, String feedBackEmailId, String emailSubject, String msg) { Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { feedBackEmailId }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSubject); emailIntent.putExtra(Intent.EXTRA_TEXT, msg); emailIntent.setType("message/rfc822"); emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (isIntentAvailable(context, emailIntent)) { context.startActivity(emailIntent); } else {/*w ww.j a va 2 s. co m*/ Toast.makeText(context, "No Email Application Found", Toast.LENGTH_LONG).show(); } }
From source file:Main.java
public static void mail(Activity activity, String email, String subject, String content) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); intent.putExtra(Intent.EXTRA_SUBJECT, subject); if (content != null) { intent.putExtra(Intent.EXTRA_TEXT, content); }/*from w ww . j a va2 s. c om*/ final PackageManager manager = activity.getPackageManager(); final List<ResolveInfo> matches = manager.queryIntentActivities(intent, 0); for (ResolveInfo info : matches) { if (info.activityInfo.packageName.endsWith(".gm") || info.activityInfo.name.toLowerCase().contains("gmail")) { intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); } else if (info.activityInfo.packageName.endsWith(".email") || info.activityInfo.name.toLowerCase().contains("email")) { intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); } } activity.startActivity(intent); }
From source file:Main.java
public static void shareToGMail(Context context, String[] email, String subject, String content) { Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emailIntent.putExtra(Intent.EXTRA_EMAIL, email); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, content); final PackageManager pm = context.getPackageManager(); final List<ResolveInfo> matches = pm.queryIntentActivities(emailIntent, 0); ResolveInfo best = null;/* w ww . j a va 2 s. c om*/ for (final ResolveInfo info : matches) if (info.activityInfo.packageName.endsWith(".gm") || info.activityInfo.name.toLowerCase().contains("gmail")) best = info; if (best != null) emailIntent.setClassName(best.activityInfo.packageName, best.activityInfo.name); context.startActivity(emailIntent); }
From source file:Main.java
public static void sendMail(Context context, String[] mail, String subject, String body) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); // i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recipient@example.com"}); // i.putExtra(Intent.EXTRA_SUBJECT, "subject of email"); // i.putExtra(Intent.EXTRA_TEXT , "body of email"); i.putExtra(Intent.EXTRA_EMAIL, mail); i.putExtra(Intent.EXTRA_SUBJECT, subject); i.putExtra(Intent.EXTRA_TEXT, body); try {/*from w ww . j av a2s. com*/ context.startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(context, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); } }
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)); }//w w w . java2s .co m return intent; }
From source file:Main.java
public static void share(Context context, String textToSend) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, textToSend); context.startActivity(Intent.createChooser(intent, "Share with...")); }
From source file:Main.java
/** * Send an email via available mail activity * // w w w .j a v a 2s. c o m * @param context the app context * @param to the email address send to * @param subject the email subject * @param body the email body */ public static void sendEmail(Context context, String to, String subject, String body) { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", to, null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, body); context.startActivity(Intent.createChooser(emailIntent, null)); }