I am using this code to call WhatsApp directly from my Call Logs app. This works well, but only if the phone number includes a valid country code. For example calling WhatsApp
Here is the complete solution. May be useful for people who are trying the same from their apps. Thanks to Sourav Ganguly for the link.
android-make whatsapp call
Use the ID from step 3 to start WhatsApp. Here is sample code:
String data = "content://com.android.contacts/data/" + dataId;
String type = "vnd.android.cursor.item/vnd.com.whatsapp.profile";
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_VIEW);
sendIntent.setDataAndType(Uri.parse(data), type);
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);