Course Content

If you are facing any issue in playing video please use Firefox browser.

Course Content

Description

Creating SMS Application in Android

 

In this video we are going to create SMS application in Android.

First of all we will design layout of our application, for that we will open main.xml file, and inside that we will see that we have taken one linearlayout, two TextView, and two EditText. We also have taken one Button which when user will click on, the SMS will be sent.

Now inside AndroidManifest.xml file, we will set certain permission like SEND_SMS and RECEIVE_SMS.

Now we will design the main code inside 'sms.java' folder. Here we have done View Identification of two EditText and one Button. We will design a switch case method here and use it.

public void sendSms(String phoneNumber, String message)

{

String sent="SMS_SENT";

PendingIntent sentPi=PendingIntent.getBroadcast(this,0,new Intent(sent),0);

@Override

public void onReceive(Context context, Intent intent)

{

switch(getResultCode())

{

case Activity.RESULT_OK:

Toast.makeText(getBaseContext(),"SMS sent",Toast.LENGTH_SHORT).show();

break;

}

Similarly we will design other case and generate specific Toast notification for them.

Now we will design a Listener for our button,

b1.setOnClickListener(new OnClickListener()

{

@Override

public void onClick(View v)

{

String a1=e1.getText().toString();

String a2=e2.getText().toString();

sendSms(s1,s2);

Now we will run our code and see how it is executed. First of all we will be asked to enter a phone number, and then the Message. After that when we click on Send SMS button, it works successfully.

FAQs

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
297K+ Downloads
App Download Section Circle 1
4.5 Rating
App Download Section Circle 2
10K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere