Reputation: 73
I have googled this but cannot find an answer, do someone know how to send android Hangouts chat message to specific number through code?
Upvotes: 0
Views: 916
Reputation: 4834
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);
Upvotes: 1
Reputation: 11331
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);
Upvotes: 0