I want open what's app conversation activity cmp=com.whatsapp/.Conversation
from my app.
How can I do this? I have contact phone number, contact id, contact raw id and also have what's app uri for a particular contact.
private void openWhatsApp(String id) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("content://com.android.contacts/data/"+id));
Log.v("ssssss", s);
i.setType("vnd.android.cursor.item/vnd.com.whatsapp.profile");
i.setComponent(new ComponentName("com.whatsapp", ".Conversation"));
startActivity(i);
}
04-20 18:13:45.794: I/ActivityManager(1862): START
{act=android.intent.action.VIEW
dat=content://com.android.contacts/data/8269
typ=vnd.android.cursor.item/vnd.com.whatsapp.profile
cmp=com.whatsapp/.accountsync.ProfileActivity} from pid 32159
04-20 18:42:11.317: I/ActivityManager(1862): START {flg=0x14000000 cmp=com.whatsapp/.Conversation (has extras)} from pid 1150
private void openWhatsApp(String id) {
Cursor c = getContentResolver().query(ContactsContract.Data.CONTENT_URI,
new String[] { ContactsContract.Contacts.Data._ID }, ContactsContract.Data.DATA1 + "=?",
new String[] { id }, null);
c.moveToFirst();
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("content://com.android.contacts/data/" + c.getString(0)));
startActivity(i);
c.close();
}
Where id is what's app uri like [email protected]
try this code :
String smsNumber="[email protected]";
Uri uri = Uri.parse("smsto:" + smsNumber);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.putExtra("sms_body", "Prakash Gajera");
i.setPackage("com.whatsapp");
startActivity(i);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With