I've gone through plenty of WhatsApp posts here in StackOverflow.
Like these: Is it legal to use WhatsAPI?
Android Whatsapp/Chat Examples
Sending message through WhatsApp
My question is this. I manage to send a message from my app to WhatsApp for someone that is in my contact list.
However, I want to send a message (NOT SPAM!) to someone who is not on my Contact List through WhatsApp, and I'm unable to do so with the given solutions.
How is it possible?
By the way, how is it possible to fill the body of a WhatsApp text field with a pre-defined message, so the user can edit or send immediately? "sms_body", or Intent.EXTRA_TEXT doesn't seem to work...
public void shareWhatsApp(String whatsappid) {
try {
Cursor c = getContentResolver().query(ContactsContract.Data.CONTENT_URI,
new String[] { ContactsContract.Contacts.Data._ID }, ContactsContract.Data.DATA1 + "=?",
new String[] { whatsappid }, null);
c.moveToFirst();
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("content://com.android.contacts/data/" + c.getString(0)));
i.putExtra(Intent.EXTRA_TEXT, "Hello!");
startActivity(i);
c.close();
} catch (Exception e) {
Toast.makeText(this, "Install WhatsApp First", Toast.LENGTH_LONG).show();;
e.printStackTrace();
}
}