Android tutorial - Android SMS | How To Send SMS in Android- android app development - android studio - android development tutorial
Learn android - android tutorial - How to send sms in android - android examples - android programs
- Manages SMS operations such as sending data, text, and pdu SMS messages. Get this object by calling the static method getDefault().
- Android, you can use Sms Manager API or devices Built-in SMS application to send SMS's.
- We can send sms in android via intent. You need to write only 4 lines of code the send sms in android.
- //Getting intent and Pending Intent instance
- Intent intent=new Intent(getApplicationContext(),MainActivity.class);
- PendingIntent pi=PendingIntent.getActivity(getApplicationContext(), 0, intent,0);
- //Get the SmsManager instance and call the sendTextMessage method to send message
- SmsManager sms=SmsManager.getDefault();
- sms.sendTextMessage("7667668009", null, "hello wikitechy", pi,null);
Example of sending sms in android
activity_main.xml
File: activity_main.xml
Write the permission code in Android-Manifest.xml file
- You need to write SEND_SMS permission as given below:
File: Android-Manifest.xml
Activity class
- Let's write the code to make the phone call via intent.