Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
Images
SendSMS reorganizing files into recipes folder Mar 7, 2018
README.md
SendSMS.sln reorganizing files into recipes folder Mar 7, 2018

README.md

id title brief sdk
ABDD6F9D-BA78-ECD5-3D2A-7E8A5CB8E6E1
Send an SMS
This recipe shows how to send an SMS message using the SMSManager or an Intent.

Recipe

There are two options for sending SMS messages on Android:

  • Use SmsManager to send messages in the background.
  • Use an intent to send the user to the SMS application with a preset number and message.

Follow these steps to send an SMS message using the SmsManager class.

  • Add the SEND_SMS permission to the Android manifest.
  • Call the SendTextMessage method of the SmsManager.
SmsManager.Default.SendTextMessage ("1234567890", null,
"Hello from Xamarin.Android", null, null);

To send an SMS message using an Intent, create the Intent with a ActionSendto action and a Uri that begins with smsto:. Include the message body in the Intent’s payload by calling PutExtra.

var smsUri = Android.Net.Uri.Parse("smsto:1234567890");
var smsIntent = new Intent (Intent.ActionSendto, smsUri);
smsIntent.PutExtra ("sms_body", "Hello from Xamarin.Android");  
StartActivity (smsIntent);

Additional Information

The permission is needed for the case where the SmsManager is used to send the SMS message programmatically. When using the Intent, this permission is not required.