如何通过内容提供商访问联系人数据

时间:2012-02-28 06:19:25

标签: android opengl-es android-intent android-contacts android-contentprovider

我想以轮播格式显示联系人。我编写了一个使用open gl es库创建3D轮播视图的应用程序。现在我想使用该应用程序显示联系人。如何将联系人数据加载到我的应用程序中?

2 个答案:

答案 0 :(得分:1)

有关详细信息,请参阅此链接

http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/2/

修改

对于Photo,请参阅下面的链接

Getting a Photo from a Contact

答案 1 :(得分:0)

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


 public void onActivityResult(int reqCode, int resultCode, Intent data) {
            super.onActivityResult(reqCode, resultCode, data);

            switch (reqCode) {
            case (PICK_CONTACT):
                if (resultCode == Activity.RESULT_OK) {
                    Uri contactData = data.getData();
                    Cursor c = managedQuery(contactData, null, null, null, null);

                    if (c.moveToFirst()) {
                        // other data is available for the Contact. I have decided
                        // to only get the name of the Contact.
                        String name = c
                                .getString(c
                                        .getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));


Toast.makeText(getApplicationContext(), name,
                 Toast.LENGTH_SHORT).show();



                    }
                }

并看到此链接

http://eclipsed4utoo.com/blog/android-open-contacts-activity-return-chosen-contact/