SmsManager.SendTextMessage throws exception

842 views Asked by At

I'm using VS 2015 and I debug from my nexus 4 device. Why this line throw exception (Same result with any phone number-including real numbers) ? (no details are shown).

SmsManager.Default.SendTextMessage("123456789", null, "bbbbb", null, null);
1

There are 1 answers

4
berkyl On BEST ANSWER

I found a sample for using SmsManager here:

SmsManager sms = SmsManager.getDefault();
PendingIntent sentPI;
String SENT = "SMS_SENT";

sentPI = PendingIntent.getBroadcast(this, 0,new Intent(SENT), 0);

sms.sendTextMessage(phoneNumber, null, message, sentPI, null);

From the comments:

sendTextMessage() method sends the SMS message with a PendingIntent.PendingIntent object is used to identify a target to invoke at a later time. We can monitor the status of the SMS message sending process this way.

And following permission is needed:

<uses-permission android:name="android.permission.SEND_SMS" />