I'm trying to send a text message from my android application to Whatsapp to specific Contact. when I'm using below codes, I am succeed either to send message and have to pickup contact manually, or If Specific number chat window opens, but message is blank. So is it possible to do both with one intent ? Here is my code:
I can share message to WhatsApp, but contact i have to choose manually:
Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.setPackage("com.whatsapp"); i.putExtra(Intent.EXTRA_TEXT, "Hello World"); try { activity.startActivity(i); } catch (Exception e) { e.printStackTrace(); }
Specific number in wats app window opens, but message is blank:
Uri uri = Uri.parse("smsto:" + number); Intent i = new Intent(Intent.ACTION_SENDTO, uri); i.putExtra("sms_body", "smsText"); i.setPackage("com.whatsapp"); activity.startActivity(i);