0

I have googled this but cannot find an answer, do someone know how to send android Hangouts chat message to specific number through code?

user2638062
  • 73
  • 2
  • 8

2 Answers2

1

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
0

Hmm, are you saying using Hangout App? which is built in as SMS app?

Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address", "12125551212");
smsIntent.putExtra("sms_body","Body of Message");
startActivity(smsIntent);
Allan Jiang
  • 11,063
  • 27
  • 104
  • 165