Send Whatsapp message to specific contact

前端 未结 8 2121
南旧
南旧 2020-12-05 05:27

I followed this link and this is my code

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(\"content://com.android.contacts/data/\" + \"MYNUMBER@s.whatsapp         


        
8条回答
  •  春和景丽
    2020-12-05 06:03

    private void openWhatsApp(String id) {
    
    Cursor c = getSherlockActivity().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

     0987654321@s.whatsapp.net
    

提交回复
热议问题