Posts

Showing posts from January, 2013

android: sending SMS programmatically

In android app, if you want to send SMS using the carrier network, you can use the below function. Pass the destination mobile number and the SMS string within specified characters.


public boolean sendSMS(String dstAddress, String smsMessage)
    {

try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(dstAddress, null, smsMessage, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS failed, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
return false;
}
return true;
    }