android - How can I share text in what's app on particular Number -
using code open particulat number's chat text not share.how can this?
public class mainactivity extends appcompatactivity { button wa; string id = "+919000000000"; edittext txt; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); txt = (edittext)findviewbyid(r.id.edittext); wa = (button)findviewbyid(r.id.btn_whatsapp); wa.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { uri uri = uri.parse("smsto:" + id); intent waintent = new intent(intent.action_sendto,uri); string text = "testing message"; waintent.setpackage("com.whatsapp"); if (waintent != null) { waintent.putextra(intent.extra_text, text); startactivity(intent.createchooser(waintent, text)); } else { toast.maketext(getapplicationcontext(), "whatsapp not found", toast.length_short) .show(); } } }); }
since trying achieve "smsto:"
, "text/plain"
type you. try "sms_body"
if won't help.
uri uri = uri.parse("smsto:" + id); intent waintent = new intent(intent.action_sendto,uri); string text = "testing message"; waintent.setpackage("com.whatsapp"); if (waintent != null) { waintent.settype("text/plain"); //waintent.putextra(intent.extra_text, text); waintent.putextra("sms_body", text); startactivity(intent.createchooser(waintent, text)); } else { toast.maketext(getapplicationcontext(), "whatsapp not found", toast.length_short) .show(); }
Comments
Post a Comment