Android : Share message directly to whatsapp contact

Whatsapp is something which doesn’t require any introduction. It’s a conversation app used by millions of users across the world. These million users make it unique for developers also to give special attention when it comes to sharing some message through Whatsapp.

During recent times, I was asked multiple times in the comments section or even emails, if there is any possible way where we can send the text message directly to a WhatsApp contact?

This post was originally posted at https://agrawalsuneet.github.io/blogs/android-share-message-directly-to-whatsapp-contact/ and reposted on Medium on 23rd Oct 2020.

The ideal way any app accepts text, image, video or any other format for sharing is through intent filters defined in the manifest file.
Whatsapp also does the same and accepts all possible format (with some size and other limitations) but that will take you to a contact selection screen in Whatsapp.

If you want to share the text directly to a contact on WhatsApp, there is a hack which is actually not documented anywhere but using the same we can achieve it.

There is an API from WhatsApp which accepts phone and text and query parameters and if you call that API, it actually opens WhatsApp, check if that number exists on WhatsApp, if yes it opens conversation with that number and paste the message. If the contact or mobile numbers doesn’t exist on WhatsApp, it shows a popup saying contact doesn’t exist on WhatsApp.

Please continue reading at https://agrawalsuneet.github.io/blogs/android-share-message-directly-to-whatsapp-contact/

That’s all for now. You can read my other interesting posts here or you can enjoy my games or apps listed here. Feel free to use my open-source Android components in your app listed here. Or drop an email, if you didn’t find what you are looking for and need some help.