Introduction

In this article, I will show you how to create an SMS Android App using Android Studio. SMS stands for Short Message Service and is also commonly referred to as a "text message". With an SMS app, you can send a message of up to 160 characters to another device. Longer messages will automatically be split into several parts. Most cell phones support this type of text messaging.
Requirements
Steps to be followed
Follow these steps to create an SMS app using Android Studio. I have attached the source code too.
Step 1
Open Android Studio and start a new Android Studio Project.
Android
Step 2
You can choose your application name and choose the location where your project is stored. If you wish to use C++ for coding the project, mark the "Include C++ support", and click the "Next" button.
Android
Step 3
Now, select the version of Android and select the target Android devices. We need to choose the SDK level which plays an important role in running the application.
Android
Step 4
Now, add the activity and click the "Next" button.
Android
Step 5
Add Activity name and click "Finish".
Android
Step 6
Go to activity_main.xml. This XML file contains the designing code for your Android app.
Android
The XML code is given below.
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@android:color/white"
          android:orientation="vertical" >
         <EditText
          android:id="@+id/editText1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true"
          android:layout_alignParentTop="true"
          android:layout_marginRight="20dp"
          android:ems="10" />
         <EditText
          android:id="@+id/editText2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/editText1"
          android:layout_below="@+id/editText1"
          android:layout_marginTop="26dp"
          android:ems="10"
          android:inputType="textMultiLine" />
         <TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/editText1"
          android:layout_alignBottom="@+id/editText1"
          android:layout_toLeftOf="@+id/editText1"
          android:text="Mobile No:" />
         <TextView
          android:id="@+id/textView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/editText2"
          android:layout_alignBottom="@+id/editText2"
          android:layout_alignLeft="@+id/textView1"
          android:text="Message:" />
         <Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/editText2"
          android:layout_below="@+id/editText2"
          android:layout_marginLeft="34dp"
          android:layout_marginTop="48dp"
          android:text="Send SMS" />
         </RelativeLayout>
         
Step 7
Go to Main Activity.java. This Java program is the backend language for Android.
Android
The java code is given below.
  1. package abu.sms;
  2. import android.os.Bundle;
  3. import android.app.Activity;
  4. import android.app.PendingIntent;
  5. import android.content.Intent;
  6. import android.telephony.SmsManager;
  7. import android.view.Menu;
  8. import android.view.View;
  9. import android.view.View.OnClickListener;
  10. import android.widget.Button;
  11. import android.widget.EditText;
  12. import android.widget.Toast;
  13. public class MainActivity extends Activity {
  14. EditText mobileno,message;
  15. Button sendsms;
  16. @Override
  17. protected void onCreate(Bundle savedInstanceState) {
  18. super.onCreate(savedInstanceState);
  19. setContentView(R.layout.activity_main);
  20. mobileno=(EditText)findViewById(R.id.editText1);
  21. message=(EditText)findViewById(R.id.editText2);
  22. sendsms=(Button)findViewById(R.id.button1);
  23. sendsms.setOnClickListener(new OnClickListener() {
  24. @Override
  25. public void onClick(View arg0) {
  26. String no=mobileno.getText().toString();
  27. String msg=message.getText().toString();
  28. Intent intent=new Intent(getApplicationContext(),MainActivity.class);
  29. PendingIntent pi=PendingIntent.getActivity(getApplicationContext(), 0, intent,0);
  30. SmsManager sms=SmsManager.getDefault();
  31. sms.sendTextMessage(no, null, msg, pi,null);
  32. Toast.makeText(getApplicationContext(), "Message Sent successfully!",
  33. Toast.LENGTH_LONG).show();
  34. }
  35. });
  36. }
  37. @Override
  38. public boolean onCreateOptionsMenu(Menu menu)
  39. getMenuInflater().inflate(R.menu.activity_main, menu);
  40. return true;
  41. }
  42. }
Step 8
We need to make Sender and Receiver requests. So, add Bluetooth permissions in an AndroidManifest.xml.
Android
The AndroidManifest.xml code is given below.
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="abu.sms">
  4. <uses-permission android:name="android.permission.SEND_SMS"/>
  5. <uses-permission android:name="android.permission.RECEIVE_SMS"/>
  6. <application
  7. android:allowBackup="true"
  8. android:icon="@mipmap/ic_launcher"
  9. android:label="@string/app_name"
  10. android:roundIcon="@mipmap/ic_launcher_round"
  11. android:supportsRtl="true"
  12. android:theme="@style/AppTheme">
  13. <activity android:name=".MainActivity">
  14. <intent-filter>
  15. <action android:name="android.intent.action.MAIN" />
  16. <category android:name="android.intent.category.LAUNCHER" />
  17. </intent-filter>
  18. </activity>
  19. </application>
  20. </manifest>
Step 9
Now, go to the menu bar and click the "Make Project" option or press ctrl+f9 to debug the error.
Android
Step 10
Then, click the "Run" button or press shift+f10 to run the project. And, choose the "virtual machine" option and click OK.
Android

Conclusion

We have successfully created an SMS Android application using the Android Studio. Here is the output.
Android
Android