有人可以解释一下如何为特定联系人 URi 打开本地联系人
我设法通过以下方式解析联系人 URI:
Uri lookupUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
Uri.encode(displayName));
然后我试着这样做:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
intent.putExtra(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, "555");
context.startActivity(intent);
但只是打开 native 通讯录,没有任何解析
最佳答案
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactID));
intent.setData(uri);
context.startActivity(intent);
您可以使用 contentResolver
浏览来检索 contactId:
id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
name = cur.getString( cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
Log.d(tag, "Id: "+ id+"\t Name: "+name);
关于android - 如何通过 URI 打开 native 名片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14674199/