How to open a contact card in Android by ID

后端 未结 3 1286
一向
一向 2020-12-09 11:23

Is it possible to open an android contact card by contact\'s ID? It works with the phone-number. Here is an example, if I use

Intent i = new Intent();
i.setA         


        
3条回答
  •  渐次进展
    2020-12-09 11:43

    use ACTION_VIEW and either build a contact URI using the contact ID or use the contact lookup URI if you already have it (preferred).

        Intent intent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactID));
        intent.setData(uri);
    context.startActivity(intent);
    

提交回复
热议问题