5

As of Hangouts 2.0 Google have broken (or undocumented) how to send SMS body from third party apps via Intent.

This renders Sending SMS via an intent from your app on 4.4 completely broken.

The following Intents do not work:

Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address", "12125551212");
smsIntent.putExtra("sms_body","Body of Message");\

And

Intent sendIntent = new Intent(Intent.ACTION_SENDTO);         
sendIntent.setData(Uri.parse("sms:"));
sendIntent.putExtra("sms_body", x); 

Hangouts completely ignores setType("vnd.android-dir/mms-sms")

Falling back to the Uri.parse method is the only option, but the app still ignores sms_body key.

At this point in time its undocumented so playing around with a few variations of %body% to no fruition.

Worth noting we tried http://www.ietf.org/rfc/rfc5724.txt to create a URI as per the spec. sms:12345666777?body=Text here but no help there.

*Note: I was using ACTION_VIEW, changed to ACTION_SENDTO, still to no avail*

Chris.Jenkins
  • 13,051
  • 4
  • 60
  • 61
  • Did you miss the follwoing blog post? http://android-developers.blogspot.be/2013/10/getting-your-sms-apps-ready-for-kitkat.html – Tobrun Nov 14 '13 at 14:09
  • "The following Intents do not work" -- I am not aware that they ever were supposed to work. Use `ACTION_SEND` and `ACTION_SENDTO`, at least with SMS. – CommonsWare Nov 14 '13 at 14:10
  • 1
    @CommonsWare ahh your right, just tested it tho, Hangouts still ignores the body. – Chris.Jenkins Nov 14 '13 at 14:20
  • Here's a dupe with a fix: http://stackoverflow.com/questions/20079047/android-kitkat-4-4-hangouts-cannot-handle-sending-sms-intent – user701632 Dec 06 '13 at 21:59

2 Answers2

1

This was fixed in hangouts 2.0.128 (2013-11-16)

Worth noting only ACTION_VIEW and ACTION_SENDTO both work now.

Chris.Jenkins
  • 13,051
  • 4
  • 60
  • 61
  • I didn't understand if you managed in the end or not, and not was fixed and what not. So if you can elaborate some more it will be great. Besides you might find this http://stackoverflow.com/a/20079048/1020530 helpful. The requirements there are without the phone number, but you might find out the solution with trial and error. Good luck – nheimann1 Nov 26 '13 at 15:48
  • @goBeepitdev Hangouts fixed the issue with the standard Intent, was a bug in the Hangouts app. Thanks for the link though. – Chris.Jenkins Nov 27 '13 at 15:14
  • I believe the Hangouts app on Android L ignores the sms body text again? – KG - Dec 17 '14 at 03:19
  • This is not fixed and is still broken in lollipop its not a Hangouts thing. – JPM Mar 26 '15 at 19:47
  • Yeah it keeps being broken and fixed. Sigh. – Chris.Jenkins Mar 27 '15 at 00:22
0

Using this you can open both hangout and messenger app.

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("smsto:"));

//Adding message which is to be sent (both are compulsory to compensate for all android versions)
intent.putExtra(Intent.EXTRA_TEXT, "shareMessage");
intent.putExtra("sms_body", "shareMessage");

//Addres which is to be sent to (Optional)
intent.putExtra("address", "12125551212"); //Optional
startActivity(intent);
Saurabh Garg
  • 4,694
  • 1
  • 11
  • 8