I want to send message to whatsapp from my Android app to specific contact without opening whatsapp app.
Currently i am using the below code to do this task. But this redirect me on whatsApp chat window for that specific number. I have to click send button in whatsApp app to send this message.
But i want to send message on Whatsapp contact in background without interaction of whatsApp app.
Any help would appreciable.
String toNumber = "+91 7889080949";
toNumber = toNumber.replace("+", "").replace(" ", "");
Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.putExtra("jid", toNumber + "@s.whatsapp.net");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Hello");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setPackage("com.whatsapp");
sendIntent.setType("text/plain");
startActivity(sendIntent);