Example usage for android.content Intent ACTION_SENDTO

List of usage examples for android.content Intent ACTION_SENDTO

Introduction

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

Prototype

String ACTION_SENDTO

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

Click Source Link

Document

Activity Action: Send a message to someone specified by the data.

Usage

From source file:Main.java

public static void sendSms(Context context, String phoneNumber, String content) {
    Uri uri = Uri.parse("smsto:" + (TextUtils.isEmpty(phoneNumber) ? "" : phoneNumber));
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.putExtra("sms_body", TextUtils.isEmpty(content) ? "" : content);
    context.startActivity(intent);//from   w w w  .ja  v  a  2 s  . c  om
}

From source file:Main.java

public static void sendSmsBySystem(Context context, String phone, String body) {
    if (TextUtils.isEmpty(phone))
        return;/*from  w  w w . j  a v  a 2 s.  c  o m*/
    Uri uri = Uri.parse("smsto:" + phone);
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.putExtra("sms_body", body);
    context.startActivity(intent);

}

From source file:Main.java

public static void sendMessage(Context activity, String phoneNumber, String smsContent) {
    if (phoneNumber == null || phoneNumber.length() < 4) {
        return;/*w  w  w. j  a  v  a 2s . c o m*/
    }
    Uri uri = Uri.parse("smsto:" + phoneNumber);
    Intent it = new Intent(Intent.ACTION_SENDTO, uri);
    it.putExtra("sms_body", smsContent);
    it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(it);
}

From source file:Main.java

/**
 * use for sending mail to any id//from w ww  . j a v a  2 s . co m
 *
 * @param mContext context
 * @param mailID   email id of whom to send mail
 */
public static void sendMail(Context mContext, String mailID) {
    Uri uri = Uri.parse("mailto:" + mailID);
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    mContext.startActivity(intent);
}

From source file:Main.java

/**  ------------------------------------------------------------------------------  Email -- */

public static boolean deviceCanHandleSendTo(final Context context) {
    return isIntentAvailable(context, Intent.ACTION_SENDTO);
}

From source file:Main.java

/**
 * Propose user to send an email with pre-filled fields.
 */// ww w. j  a v  a 2 s .c  o m
public static void sendEMail(final Context context, final String dialogTitle, final String to,
        final String subject, final String body) {
    final Intent send = new Intent(Intent.ACTION_SENDTO);
    final String uriText = "mailto:" + Uri.encode(to) + "?subject=" + Uri.encode(subject) + "&body="
            + Uri.encode(body);
    send.setData(Uri.parse(uriText));
    context.startActivity(Intent.createChooser(send, dialogTitle));
}

From source file:Main.java

public static void sendSmsByPhoneAndContext(Context context, String phone, String content) {
    phone = TextUtils.isEmpty(phone) ? "" : phone;
    content = TextUtils.isEmpty(content) ? "" : content;

    Uri uri = Uri.parse("smsto:" + phone);
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.putExtra("sms_body", content);
    context.startActivity(intent);/*from ww w . j  a v a  2 s.c om*/
}

From source file:Main.java

public static void callSystemSmsAction(Context context, String phone, String content) {
    Uri uri = Uri.parse("smsto:" + (TextUtils.isEmpty(phone) ? "" : phone));
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.putExtra("sms_body", TextUtils.isEmpty(content) ? "" : content);
    context.startActivity(intent);/*from w w  w .  j a  v  a 2s . co  m*/
}

From source file:Main.java

/**
 * Easily create email intent//from w  ww. j a va  2 s. co  m
 * 
 * @param recipientsList
 * @param ccList
 * @param subject
 * @param htmlBody
 * @return email intent chooser
 */
public static Intent createEmailIntent(List<String> recipientsList, List<String> ccList, String subject,
        CharSequence htmlBody) {
    Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
    // emailIntent.setData(Uri.parse("mailto:"));

    if (recipientsList != null) {
        for (String email : recipientsList) {
            emailIntent.putExtra(Intent.EXTRA_EMAIL, email);
        }
    }
    if (ccList != null) {
        for (String email : ccList) {
            emailIntent.putExtra(Intent.EXTRA_EMAIL, email);
        }
    }
    if (subject != null)
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    if (htmlBody != null)
        emailIntent.putExtra(Intent.EXTRA_TEXT, htmlBody);

    return emailIntent;
}

From source file:Main.java

/**
 * Send an email via available mail activity
 * //from   w w w  . j  ava  2  s  .  com
 * @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));
}