Search This Blog

05 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;
    }

No comments:

Post a Comment

tmux enabling mouse interaction

Add the below line to the ~/.tmux.conf setw -g mouse on save the file and exit from the tmux shell, you should be able to use your mouse to ...