如何在 ContactsContract.Contacts 中定义照片 uri?
我正在尝试开发一个查询来检索联系人。但是,Eclipse 不断告诉我 PHOTO_THUMBNAIL_URI 和 PHOTO_URI 无法解析或者不是字段。这是我的代码:
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
};
我该如何解决这个问题?
I am trying to develop a query to retrieve contacts. However, Eclipse keeps telling me that PHOTO_THUMBNAIL_URI and PHOTO_URI cannot be resolved 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PHOTO_THUMBNAIL_URI 和 PHOTO_URI 仅自 API 级别 11 (Android 3.0) 起可用。确保相应地设置您的项目/清单。
对于项目,在 Eclipse 中,您需要进入项目属性,然后在 Android 部分中选择“Android 3.0”(或更高版本)。对于清单,您需要类似的内容:
如果您需要应用程序在 Android 上的早期版本上运行,您可能需要使用 支持包,以将其保留在单个 APK 和代码库中。
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:
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.