Example usage for android.content Intent EXTRA_SUBJECT

List of usage examples for android.content Intent EXTRA_SUBJECT

Introduction

In this page you can find the example usage for android.content Intent EXTRA_SUBJECT.

Prototype

String EXTRA_SUBJECT

To view the source code for android.content Intent EXTRA_SUBJECT.

Click Source Link

Document

A constant string holding the desired subject line of a message.

Usage

From source file:Main.java

public static void sendEmail(Context ctx, String[] emailAddresses, String[] CCAddresses, String subject,
        String message) {//from  w  ww.jav a2 s  .  co  m

    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    // emailIntent.setType("text/plain");
    emailIntent.setData(Uri.parse("mailto:"));
    String[] to = emailAddresses;
    String[] cc = CCAddresses;
    emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
    if (CCAddresses != null) {
        emailIntent.putExtra(Intent.EXTRA_CC, cc);
    }
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, message);
    emailIntent.setType("message/rfc822");

    ctx.startActivity(Intent.createChooser(emailIntent, "Email"));

}

From source file:Main.java

/**
 * Send an email via available mail activity
 * //from  w w  w . ja  v  a2 s. co m
 * @param context       the app context
 * @param to            the email address send to
 * @param subject       the email subject
 * @param body          the email body
 * @param attachments   the uris for attachments
 */
public static void sendEmail(Context context, String to, String subject, String body, Uri... attachments) {
    Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);

    emailIntent.setType("plain/text");
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, body);

    if (attachments != null && attachments.length != 0) {
        ArrayList<Uri> uris = new ArrayList<Uri>();

        for (int i = 0; i < attachments.length; i++)
            uris.add(attachments[i]);

        emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    }

    context.startActivity(Intent.createChooser(emailIntent, null));
}

From source file:Main.java

/**
 * Lancia la finestra per la selezione di un gestore per la condivisione di un messaggio
 * (twitter, facebook, ....)./*ww w . j  a  v  a2  s . com*/
 * 
 * @param context
 * @param dialogTitle - Titolo della finestra di dialog (Share...)
 * @param subject - Subject (della email o titolo di twitter)
 * @param text - Testo del messaggio
 */
public static void share(Context context, String dialogTitle, String subject, String text) {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    context.startActivity(Intent.createChooser(intent, dialogTitle));
}

From source file:com.renard.ocr.main_menu.ContactActivity.java

public static Intent getFeedbackIntent(String subject, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    if (subject != null) {
        intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    }/*from   w w w . j ava2  s  . c o  m*/
    if (body != null) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }
    intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL });
    return intent;
}

From source file:com.example.linhdq.test.main_menu.ContactActivity.java

public static Intent getFeedbackIntent(String subject, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    if (subject != null) {
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    }/*from   w  w w.  j a  v  a  2  s .  co  m*/
    if (body != null) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL });
    return intent;
}

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:com.github.akinaru.rfdroid.menu.MenuUtils.java

/**
 * Execute actions according to selected menu item
 *
 * @param menuItem MenuItem object/*from   www  . jav a  2s  .com*/
 * @param mDrawer  navigation drawer
 * @param context  android context
 */
public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context) {

    switch (menuItem.getItemId()) {
    case R.id.switch_chart_data: {
        break;
    }
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "kiruazoldik92@gmail.com", null));
        intent.putExtra(Intent.EXTRA_SUBJECT, "RFdroid Issue");
        intent.putExtra(Intent.EXTRA_TEXT, "Your error report here...");
        context.startActivity(Intent.createChooser(intent, "Report a problem"));
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog d = new OpenSourceItemsDialog(context);
        d.show();
        break;
    }
    case R.id.about_app: {
        AboutDialog dialog = new AboutDialog(context);
        dialog.show();
        break;
    }
    }
    mDrawer.closeDrawers();
}

From source file:com.contentecontent.cordova.plugins.share.Share.java

private void doSendIntent(String subject, String text, String imagePath, String mimeType) {
    Uri parsedUri = Uri.parse(imagePath);
    Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
    sendIntent.setType(mimeType);//www .  ja v  a  2 s  . c  o m
    sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
    sendIntent.putExtra(android.content.Intent.EXTRA_STREAM, parsedUri);
    this.cordova.startActivityForResult(this, sendIntent, 0);
}

From source file:com.manning.androidhacks.hack036.util.LaunchEmailUtil.java

public static void launchEmailToIntent(Context context) {
    Intent msg = new Intent(Intent.ACTION_SEND);

    StringBuilder body = new StringBuilder("\n\n----------\n");
    body.append(EnvironmentInfoUtil.getApplicationInfo(context));

    msg.putExtra(Intent.EXTRA_EMAIL, context.getString(R.string.mail_support_feedback_to).split(", "));
    msg.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.mail_support_feedback_subject));
    msg.putExtra(Intent.EXTRA_TEXT, body.toString());

    msg.setType("message/rfc822");
    context.startActivity(Intent.createChooser(msg, context.getString(R.string.pref_sendemail_title)));
}

From source file:Main.java

/**
 * Intent chooser is customized to remove unwanted apps.
 * 1. FaceBook has bug where only links can be shared.
 * 2. Cannot share this type of content via Google Docs and Skype.
 *//*ww w . j av a 2s .co m*/
public static void ShareResult(Context mContext, String mResult, String mTitle) {
    List<Intent> targetedShareIntents = new ArrayList<Intent>();
    Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    List<ResolveInfo> resInfo = mContext.getPackageManager().queryIntentActivities(shareIntent, 0);
    if (!resInfo.isEmpty()) {
        for (ResolveInfo resolveInfo : resInfo) {
            String packageName = resolveInfo.activityInfo.packageName;
            Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND);
            targetedShareIntent.setType("text/plain");
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mTitle);
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_TITLE, mTitle);
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, mResult);
            if (!packageName.toLowerCase().contains("com.facebook.katana")
                    && !packageName.toLowerCase().contains("com.google.android.apps.docs")
                    && !packageName.toLowerCase().contains("com.skype.raider")) {
                targetedShareIntent.setPackage(packageName);
                targetedShareIntents.add(targetedShareIntent);
            }
        }
        Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Send your result");
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[] {}));
        mContext.startActivity(chooserIntent);
    }
    return;
}