Android Send SMS Using Intent

 

Android Send SMS :

 

Android send sms, Sending SMS using Android Intent

 

1. Fetch mobile number for which message to be sent

 Uri uri = Uri.parse("smsto:" + "9876543210");

 

2. Add intent using which sms is sent

 Intent smsIntent = new Intent(Intent.ACTION_SENDTO, uri);

 

3. Add message content here

 smsIntent.putExtra("sms_body", "Hi,How are you");

 

4. Start intent

 startActivityForResult(smsIntent,1);

 

Uri uri = Uri.parse("smsto:" + cellNumberEditText.getText().toString());
 Intent smsIntent = new Intent(Intent.ACTION_SENDTO, uri);
 smsIntent.putExtra("sms_body", smsMessageEditText.getText().toString());
 startActivityForResult(smsIntent,1);

 

if you want to trace the status of the message whether it is sent or not

 

@Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 super.onActivityResult(requestCode, resultCode, data);
 if(requestCode==1){
 Toast.makeText(this, "Sent Message "+requestCode, Toast.LENGTH_SHORT).show();
 }else{
 Toast.makeText(this, "Failed "+requestCode, Toast.LENGTH_SHORT).show();
 }
 }

Show Buttons
Hide Buttons
Read previous post:
Get video code from Youtube Link || Youtube video code

  Want to fetch the Youtube video code from the youtube url to play youtube video? Integrate youtube video ???...

Close