如何通过ID在Android开放名片 [英] How to open a contact card in Android by ID
问题描述
是它可以通过联系人的身份证开的机器人名片?它的工作原理与手机号码。下面是一个例子,如果我用
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
意向书我=新意图(); i.setAction(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
i.setData(Uri.fromParts(电话,123456,NULL)); //< ----在这里改变从手机向IDcontext.startActivity(我);
Intent i = new Intent(); i.setAction(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
i.setData(Uri.fromParts("tel", "123456", null)); //<---- Change here from Phone to IDcontext.startActivity(i);
我会看到这样的:
不过,我想打开这个名片用的ID,例如,如果从联系人的电话号码会改变。
But I want to open this contact card by ID, for example if the phone-number from the contact would change.
推荐答案
使用ACTION_VIEW,要么使用接触式ID建立联系URI或使用联系人查找的URI,如果你已经拥有了它(preferred)。
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);
这篇关于如何通过ID在Android开放名片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!