import android.telephony.SmsManager;
private boolean send(String number, String message) {
boolean b = true;
Log.i(MainActivity.class.getName(),">>Sending sms ::: " + number + " with message ::: " + message);
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(number, null, message, null, null);
Log.i(MainActivity.class.getName(),">>Sent - OK!");
}catch (Exception e) {
b = false;
e.printStackTrace();
}
return b;
}//End method
Below lines of code should be added to AndroidManifest.xml.
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS"/>
No comments:
Post a Comment