List of usage examples for android.content Intent EXTRA_SUBJECT
String EXTRA_SUBJECT
To view the source code for android.content Intent EXTRA_SUBJECT.
Click Source Link
From source file:Main.java
public static boolean share(Context context, String title, String content) { Intent send = new Intent(Intent.ACTION_SEND); send.setType("text/plain"); send.putExtra(Intent.EXTRA_TEXT, content); send.putExtra(Intent.EXTRA_SUBJECT, title); try {//from w ww .j a va 2 s. c om context.startActivity(Intent.createChooser(send, content)); } catch (android.content.ActivityNotFoundException ex) { return false; } return true; }
From source file:Main.java
public static Intent newEmailIntent(String toAddress, String subject, String body, String cc) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { toAddress }); intent.putExtra(Intent.EXTRA_TEXT, body); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_CC, cc); intent.setType("message/rfc822"); return intent; }
From source file:Main.java
public static Intent newEmailIntent(Context context, String address, String subject, String body, String cc) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address }); intent.putExtra(Intent.EXTRA_TEXT, body); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_CC, cc); intent.setType("message/rfc822"); return intent; }
From source file:Main.java
public static void shareViaEmail(Context context, String subject, String text) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setType("text/html"); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_SUBJECT, subject); context.startActivity(Intent.createChooser(intent, "Share via Email")); }
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 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);//w ww . j a v a2 s .com ei.putExtra(Intent.EXTRA_TEXT, extra_text); ei.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); return ei; }
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);// w w w . j a v a2 s. c om 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 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 w w . jav a2 s . co m*/ 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;/*from ww w .j a v a 2 s. c o m*/ 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 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 {//from w w w . j a v a2 s . c om Toast.makeText(context, "No Email Application Found", Toast.LENGTH_LONG).show(); } }