0

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);
Tammy
  • 7
  • 2
  • I have the same question how does Google app in android devices do that...? It sends whatsapp messages without opening it... – Xenolion Mar 21 '18 at 09:34
  • I don't think that you can do this. @Xenolion what Google app does this? – Iulian Popescu Mar 21 '18 at 09:38
  • There is an app in android devices called `Google` itself. Open it and Just say **Ok Google** Then say **Send a whatsapp message to Someone**. It just send without opening whatsapp. And when you open whatsapp you will frind your message sent.... I was also suprised with this @lulian – Xenolion Mar 21 '18 at 09:43
  • This is an app on playstore that send message on whatsapp in background, link:- https://play.google.com/store/apps/details?hl=en&id=tkstudio.wachatbotlite How it works ? – Tammy Mar 21 '18 at 09:46
  • Well, it looks like it needs rooted devices to work. Since, Facebook didn't provide a public API for this, you should do it in the classic way. It's saffer that way. – Iulian Popescu Mar 21 '18 at 09:56
  • No, I have used this app. it works fine to send text messages on whatsapp without routing phone. – Tammy Mar 21 '18 at 10:10
  • https://stackoverflow.com/questions/49654674/send-message-via-whatsapp-programmatically – Soon Heng Sep 30 '19 at 02:05

0 Answers0