简体   繁体   English

如何在Android中使用Intent打开联系人

[英]How to open Contact using intent in android

I have been using the following code to open contact in android. 我一直在使用以下代码在android中打开联系人。 But it is not showing symbol of contactID and context 但是它没有显示contactID上下文的符号

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

Try this code.. its working for me 试试这个代码..它为我工作

  Intent intent = new Intent(Intent.ACTION_VIEW);

    intent.setDataAndType(uri, "vnd.android.cursor.dir/contact");
    context.startActivity(intent);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM