gpt4 book ai didi

android - 如何在 android 中启动 'Add Contact' Activity

转载 作者:IT王子 更新时间:2023-10-29 00:10:04 24 4
gpt4 key购买 nike

您能告诉我如何在 android 中启动“添加联系人” Activity 吗?谢谢。

最佳答案

API Level 5 及以上解决方案

// Add listener so your activity gets called back upon completion of action,
// in this case with ability to get handle to newly added contact
myActivity.addActivityListener(someActivityListener);

Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);

// Just two examples of information you can send to pre-fill out data for the
// user. See android.provider.ContactsContract.Intents.Insert for the complete
// list.
intent.putExtra(ContactsContract.Intents.Insert.NAME, "some Contact Name");
intent.putExtra(ContactsContract.Intents.Insert.PHONE, "some Phone Number");

// Send with it a unique request code, so when you get called back, you can
// check to make sure it is from the intent you launched (ideally should be
// some public static final so receiver can check against it)
int PICK_CONTACT = 100;
myActivity.startActivityForResult(intent, PICK_CONTACT);

关于android - 如何在 android 中启动 'Add Contact' Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1895206/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com