0

I want to execute the compose message - SMS (Default application in the android phones) after a user clicked a Button inside my android app.

Is this imposibble?

Saro Taşciyan
  • 5,210
  • 5
  • 31
  • 50

1 Answers1

0

You can use below code to send sms in android:

Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setData(Uri.parse("smsto:"));
smsIntent.setType("vnd.android-dir/mms-sms");

smsIntent.putExtra("address"  , new String ("0123456789"));
smsIntent.putExtra("sms_body"  , "Test SMS Body");
try {
    startActivity(smsIntent);
    finish();
    Log.i("Finished sending SMS...", "");
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(MainActivity.this, 
    "SMS faild, please try again later.", Toast.LENGTH_SHORT).show();
}

Hope it will help you..

Rushabh Patel
  • 3,052
  • 4
  • 26
  • 58