开发者

How to define Photo uri in ContactsContract.Contacts?

I am trying to develop a query to retrieve contacts. However, Eclipse keeps telling me that PHOTO_THUMBNAIL_URI and PHOTO_URI cannot be resolve开发者_如何学God or is not a field. Here's my code:

Uri uri = ContactsContract.Contacts.CONTENT_URI;
    String[] projection = new String[] {
            ContactsContract.Contacts._ID,
            ContactsContract.Contacts.DISPLAY_NAME,
            ContactsContract.Contacts.HAS_PHONE_NUMBER,
            ContactsContract.Contacts.LOOKUP_KEY,
            ContactsContract.Contacts.PHOTO_THUMBNAIL_URI,
            ContactsContract.Contacts.PHOTO_URI,
            ContactsContract.Contacts.PHOTO_ID
    };

How do I solve this?


The PHOTO_THUMBNAIL_URI and PHOTO_URI are only available since API level 11 (Android 3.0). Make sure to set up your project/manifest accordingly.

For the project, in Eclipse, you'll need to go into your project properties, then, in the Android section, select "Android 3.0" (or higher). For the manifest, you'll need something like that:

<uses-sdk android:minSdkVersion="11"/>

If you need your application to work on prior versions on Android, you might want to use a Support package to keep it to a single APK and code base.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜