Android. Set phone number when sending message by hangout -


i want set phone number when send message hangout.

when use sms, can done below.

intent sendintent = new intent(intent.action_view); sendintent.setdata(uri.parse("sms:")); sendintent.putextra("sms_body", message); sendintent.putextra("adress", phonenumber); context.startactivity(sendintent); 

but don't know how set phone number or target phone number in hangout.. here current code using hangout.

    if (build.version.sdk_int >= build.version_codes.kitkat) //at least kitkat     {         string defaultsmspackagename = telephony.sms.getdefaultsmspackage(context);          intent sendintent = new intent(intent.action_send);         sendintent.settype("text/plain");         sendintent.putextra(intent.extra_text, message);          if (defaultsmspackagename != null)         {             sendintent.setpackage(defaultsmspackagename);         }         context.startactivity(sendintent);     } 

edited..!

i found solution here. see @roberto b.'s solution.

i used following code recently, , seems work require:

public static void sendsms(activity activity, string message, string phonenumber){          intent smsintent;          if (build.version.sdk_int >= build.version_codes.kitkat){             smsintent = new intent(intent.action_sendto);             //ensures sms apps respond             smsintent.setdata(uri.parse("smsto:" + phonenumber));              //no resolvable activity             if (smsintent.resolveactivity(activity.getpackagemanager()) == null) {                 return;             }          }else{             //old way of accessing sms activity             smsintent = new intent(intent.action_view);             smsintent.settype("vnd.android-dir/mms-sms");             smsintent.putextra("address", phonenumber);             smsintent.putextra("exit_on_sent", true);         }         smsintent.putextra("sms_body", message);         activity.startactivity(smsintent);     } 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -