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 void openMailChooser(Context context, String text, String[] mails, String subject) { Intent mailIntent = new Intent(); mailIntent.setAction(Intent.ACTION_SEND); mailIntent.putExtra(Intent.EXTRA_TEXT, text); mailIntent.putExtra(Intent.EXTRA_EMAIL, mails); mailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); mailIntent.setType(INTENT_TYPE_MSG); PackageManager pm = context.getPackageManager(); Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType(INTENT_TYPE_TEXT); Intent openInChooser = Intent.createChooser(mailIntent, ""); List<ResolveInfo> resInfo = pm.queryIntentActivities(sendIntent, 0); List<LabeledIntent> intentList = new ArrayList<LabeledIntent>(); for (ResolveInfo ri : resInfo) { String packageName = ri.activityInfo.packageName; if (packageName.contains(PACKAGE_EMAIL)) { mailIntent.setPackage(packageName); } else if (packageName.contains(PACKAGE_MMS) || packageName.contains(PACKAGE_GMAIL)) { Intent intent = new Intent(); intent.setComponent(new ComponentName(packageName, ri.activityInfo.name)); intent.setAction(Intent.ACTION_SEND); intent.setType(INTENT_TYPE_TEXT); if (packageName.contains(PACKAGE_MMS)) { intent.putExtra("subject", subject); intent.putExtra("sms_body", text); intent.putExtra("address", mails[0]); intent.setType(INTENT_TYPE_MSG); } else if (packageName.contains(PACKAGE_GMAIL)) { intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_EMAIL, mails); intent.setType(INTENT_TYPE_MSG); }//from ww w . j a v a 2 s . co m intentList.add(new LabeledIntent(intent, packageName, ri.loadLabel(pm), ri.icon)); } } LabeledIntent[] extraIntents = intentList.toArray(new LabeledIntent[intentList.size()]); openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents); context.startActivity(openInChooser); }
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 w w w.java 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 callSysShare(Context context, String chooserTitle, String shareTitle, String shareText, String mime, Uri uri) {/*from w ww.j av a 2 s . c o m*/ Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Intent.EXTRA_TEXT, shareText); intent.putExtra(Intent.EXTRA_SUBJECT, shareTitle); intent.setType(mime); if (uri != null) { intent.putExtra(Intent.EXTRA_STREAM, uri); } context.startActivity(Intent.createChooser(intent, chooserTitle)); }
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); }/*from ww w . j a v a 2s. com*/ 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: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 ww w . j a v a 2s . c om*/ "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; }
From source file:Main.java
public static Intent getAndroidShareIntent(CharSequence chooseTitle, CharSequence subject, CharSequence content) {/*w w w. j av a 2 s . com*/ Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject); shareIntent.putExtra(Intent.EXTRA_TEXT, content); return Intent.createChooser(shareIntent, chooseTitle); }
From source file:Main.java
/** * Drafts an email to the given email address, with the given subject line and message * @param context//from w w w. ja va 2s. c o m * @param emailAddress * @param subject * @param message */ public static void emailDeveloper(Context context, String emailAddress, String subject, String message) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] { emailAddress }); i.putExtra(Intent.EXTRA_SUBJECT, subject); i.putExtra(Intent.EXTRA_TEXT, message); context.startActivity(i); }
From source file:Main.java
public static void sendFeedback2(Context context) { String versionName = ""; try {// w w w . j a v a2s. c om versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } StringBuffer sb = new StringBuffer(); sb.append("We would like to hear your feedback and improvement ideas. Please feel free to share below :") .append("\r\n").append("\r\n").append("\r\n").append("Attach Screenshots (if any) : ") .append("\r\n").append("\r\n").append("\r\n").append("Running on ").append(android.os.Build.MODEL) .append("\r\n").append("OS Version : ").append(android.os.Build.VERSION.RELEASE).append("\r\n") .append("Client Version : ").append(versionName); Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "messageplus_feedback@starhub.com", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Message+ - Feedback"); emailIntent.putExtra(Intent.EXTRA_TEXT, sb.toString()); context.startActivity(Intent.createChooser(emailIntent, "Choose email client")); }
From source file:Main.java
public static void sendEmail(Context context, String chooserTitle, String mailAddress, String subject, String preContent) {/*from w w w.ja v a 2 s . com*/ 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)); }
From source file:Main.java
public static void share(Context pContext, String urlToShare, String titleChosser, String subject) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, urlToShare); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); pContext.startActivity(Intent.createChooser(intent, titleChosser)); }