Houcine
Houcine

Reputation: 24181

how can i set the Text Message by default when i start the SMS activity from my App?

i launch the Default SMS Activity from my Android app in order to send an SMS , using the following Code :

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("sms:"));
startActivity(intent);

but i want to Set some text directly in my EditText which contain the text message ( when i launch the Default SMS Activity , the EditText is empty ) . how can i do this ?

Regards,

Upvotes: 0

Views: 1000

Answers (2)

akkilis
akkilis

Reputation: 1934

This code works for me:
Intent smsIntent = new Intent(Intent.ACTION_VIEW); smsIntent.setData(Uri.parse("sms:"));
smsIntent.putExtra("sms_body", "share text");
startActivity(smsIntent);

Upvotes: 1

slayton
slayton

Reputation: 20309

Its really simple. Just add sms_body data to the intent

String messageBody = "This sms message"
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("sms:"));
intent.putExtra( "sms_body", messageBody );
startActivity(intent);

Upvotes: 5

Related Questions