Example usage for android.telephony SmsManager sendTextMessage

List of usage examples for android.telephony SmsManager sendTextMessage

Introduction

In this page you can find the example usage for android.telephony SmsManager sendTextMessage.

Prototype

public void sendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent,
        PendingIntent deliveryIntent) 

Source Link

Document

Send a text based SMS.

Usage

From source file:Main.java

public static void sendSMS(String phoneNumber, String message) {
    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, message, null, null);
}

From source file:Main.java

public static void sendMesage(String phoneNumber, String message) {
    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(phoneNumber, null, message, null, null);
}

From source file:Main.java

public static void sendMess(String phoneNumber, String smsBody) {
    try {//  w w  w.  j  a v  a2  s .c  o  m
        SmsManager smsManager = SmsManager.getDefault();
        smsManager.sendTextMessage(phoneNumber, null, smsBody, null, null);
        Log.w("PHONE", "SEND TO " + phoneNumber);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void sendSMS(String phoneNo, String message, Context context) {
    Log.i("Sending SMS to " + phoneNo, "");

    try {/*ww w  .j a  va 2  s  .com*/
        SmsManager smsManager = SmsManager.getDefault();
        smsManager.sendTextMessage(phoneNo, null, message, null, null);
        Toast.makeText(context, "SMS sent to " + phoneNo, Toast.LENGTH_SHORT).show();
    } catch (Exception e) {
        Toast.makeText(context, "SMS sending failed to " + phoneNo, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
}

From source file:Main.java

public static void sendSMS(String phoneNo, String message) {
    Log.i("Sending SMS to " + phoneNo, "");

    try {//from   w w  w.  j a va 2 s  . co m
        SmsManager smsManager = SmsManager.getDefault();
        smsManager.sendTextMessage(phoneNo, null, message, null, null);

    } catch (Exception e) {

        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * Method for sending a text message to the sms-oracle
 * //from w ww .j a  va 2  s . c om
 * @param phoneNumber
 * @param message
 * @param context
 */
public static void sendSMS(String phoneNumber, String message, Context context) {

    SmsManager sms = SmsManager.getDefault();

    try {
        sms.sendTextMessage(phoneNumber, null, message, null, null);
    } catch (Exception e) {
        Toast.makeText(context, "Meding ikke sendt", Toast.LENGTH_LONG).show();
    }
}

From source file:Main.java

/**
 * Method to send SMS message with a Pending Intent 
 * //from w w w .j  a v  a 2 s . c  o  m
 * @param phoneNumber The phone number that the message is to be sent to
 * @param body content of the SMS message
 * @param sentPI Pending intent that receives broadcast of when message is sent (To write the action into the database if sent successfully)
 */
public static void sendSms(String phoneNumber, String body, PendingIntent sentPI) {

    SmsManager sms = SmsManager.getDefault();
    try {
        sms.sendTextMessage(phoneNumber, null, body, sentPI, null);
    } catch (Exception e) {
        Log.d("WipiwayController", e.toString());
    }

}

From source file:Main.java

/**
 * Method to send SMS message/*w w  w.ja  va2 s.co  m*/
 * 
 * @param phoneNumber The phone number that the message is to be sent to
 * @param body content of the SMS message
 */
public static void sendSms(String phoneNumber, String body) {

    Log.d("WipiwayUtils", "Sending SMS message - " + body + " ... Phone number - " + phoneNumber);

    SmsManager sms = SmsManager.getDefault();
    try {
        sms.sendTextMessage(phoneNumber, null, body, null, null);
    } catch (Exception e) {
        Log.d("WipiwayController", e.toString());
    }

    // Show in outbox - http://stackoverflow.com/a/3873328/804503

}

From source file:Main.java

public static void sendSMS(Context context, String number, String content) {
    SmsManager smsManager = SmsManager.getDefault();
    PendingIntent sendIntent = PendingIntent.getBroadcast(context, 0, new Intent(), 0);
    smsManager.sendTextMessage(number, null, content, sendIntent, null);
}

From source file:Main.java

public static void sendSms(Context context, String number, String messageContent) {
    SmsManager smsManager = SmsManager.getDefault();
    List<String> contentList = smsManager.divideMessage(messageContent);
    for (String content : contentList) {
        smsManager.sendTextMessage(number, null, content, null, null);
    }/*from w w w .  j  a  v a  2 s . c  o m*/
}