如何从Android中的Intent获取联系信息?

时间:2012-03-10 06:01:38

标签: android cursor android-contacts

我正在使用意图来显示联系人列表。从联系人我想获得联系信息,如firstname,secondname,emailid,phonenumber。我希望onActivityForResult()中的所有信息都适用于所选联系人。

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);  
startActivityForResult(intent, 1);

1 个答案:

答案 0 :(得分:4)

这已经多次回答了,请查看这些帖子:

How to read contacts on Android 2.0

get contact info from android contact picker

How to call Android contacts list?

Google Android开发人员文档:

@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle args) {
    /*
     * Appends the search string to the base URI. Always
     * encode search strings to ensure they're in proper
     * format.
     */
    Uri contentUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(mSearchString));

    return new CursorLoader(
        getActivity(),
        contentUri,
        PROJECTION,
        null,
        null,
        null
    );
}

来源: http://developer.android.com/training/contacts-provider/retrieve-names.html