Since you're probably already familiar with SMS (or text) messages, we won't spend time explaining what they are or why they are important. (If you're not familiar with SMS or want more information, see the link provided in the See also section of this recipe.) This recipe will demonstrate how to send an SMS message. (The next recipe will demonstrate how to receive notifications of new messages and how to read existing messages.)
Create a new project in Android Studio and call it SendSMS
. Use the default Phone & Tablet
options and select Empty Activity
in the Add an Activity
to Mobile
dialog.
First, we need to add the necessary permissions for sending an SMS. Then, we'll create a layout with phone number and message fields and a Send button. When the Send button is clicked, we'll create and send the SMS. Here are the steps:
- Open the Android Manifest and add the following permission:
<uses-permission android:name="android.permission...