ContactsContract.Directory - 如何返回照片? [英] ContactsContract.Directory - How do I return a Photo?

查看:242
本文介绍了ContactsContract.Directory - 如何返回照片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚为什么我似乎无法通过照片的URI(Uri.parse(HTTP://url/image.png)),通过ContactsContract.Directory到联系人应用程序

I am trying to figure out why I can't seem to pass a photo Uri (Uri.parse(http://url/image.png)) to the contacts app via ContactsContract.Directory

我有一个Web服务,它允许搜索地址簿中。其中一个返回的字段是驻留在我已经验证是从我的蜂窝平板可访问的网络服务器联系的网址。

I have a web service which allows searching of an address book. One of the returned fields is a url of the contact which resides on a webserver which I have verified is accessible from my Honeycomb Tablet.

我ContactsContract.Directory似乎是工作完美返回结果,但是当我传回的筛选器查询Contacts.PHOTO_THUMBNAIL_URI的一部分瓦特/ Uri.parse(HTTP://url/image.png)搜索结果中仍回报不如预期,但我仍然只看到暂时的模板。

My ContactsContract.Directory seems to be working flawlessly returning results, but when I pass back as part of the FILTER query Contacts.PHOTO_THUMBNAIL_URI w/ the Uri.parse(http://url/image.png) the search results still return as expected, but I still only see the temporary template.

该目录查询的URI有支持的照片的选项。

The uri for the directory query has an option for photo supported.

if (column.equals(Directory.PHOTO_SUPPORT)) {
                    row[i] = Directory.PHOTO_SUPPORT_FULL;
                }

我已经试过Directory.PHOTO_SUPPORT *的所有组合并没有似乎有所作为。

I have tried all combinations of Directory.PHOTO_SUPPORT* and none seem to make a difference.

我唯一想到的是联系人应用程序不支持从一个URL下载照片。所以,我也试过

My only thought is that the contacts app does not support downloading photos from a URL. So I also tried

    File myFile  = new File("/sdcard/testuser.jpg");
row[photoUri] = Uri.fromFile(myFile);

和我核实,testuser.jpg是在SD卡。这工作得很好。然而,由于该目录搜索完成,我想加载它的飞行,并没有缓存(暂时)到SD卡的方式。

And I verified that testuser.jpg was on the sdcard. This worked fine. However due to the way the directory search is done I would like to load it on the fly, and not cache (for the time being) to the sdcard.

任何帮助将是AP preciated。

Any help would be appreciated.

推荐答案

我想我已经找到了答案..看起来像被详细记录被异常(有我的logcat设置为调试)。反正是pretty肯定这一点,但貌似还有对于http URI没有提供。关创建一个内容提供商,只是不知道我怎么会从内容提供商返回图像,但会看着办吧。任何提示/技巧将是AP preciated并给予答复信贷。

I think I have found the answer.. Looks like the exception was being logged in Verbose (had my logcat set at Debug). Anyway, was pretty sure about this, but looks like there is no Provider for http uri. Off to create a content provider, just not sure how I will return an image from a content provider, but will figure it out. Any hints/tips would be appreciated and given answer credit.

09-16 10:20:25.550: VERBOSE/ContactPhotoManager(11691): java.io.FileNotFoundException: No content provider: http://domain/testimage.jpg
09-16 10:20:25.550: VERBOSE/ContactPhotoManager(11691):     at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:595)
09-16 10:20:25.550: VERBOSE/ContactPhotoManager(11691):     at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:527)
09-16 10:20:25.550: VERBOSE/ContactPhotoManager(11691):     at android.content.ContentResolver.openInputStream(ContentResolver.java:362)
09-16 10:20:25.550: VERBOSE/ContactPhotoManager(11691):     at com.android.contacts.ContactPhotoManagerImpl$LoaderThread.loadRemotePhotos(ContactPhotoManager.java:722)
09-16 10:20:25.550: VERBOSE/ContactPhotoManager(11691):     at com.android.contacts.ContactPhotoManagerImpl$LoaderThread.loadPhotosInBackground(ContactPhotoManager.java:652)
09-16 10:20:25.550: VERBOSE/ContactPhotoManager(11691):     at com.android.contacts.ContactPhotoManagerImpl$LoaderThread.handleMessage(ContactPhotoManager.java:563)
09-16 10:20:25.550: VERBOSE/ContactPhotoManager(11691):     at android.os.Handler.dispatchMessage(Handler.java:95)
09-16 10:20:25.550: VERBOSE/ContactPhotoManager(11691):     at android.os.Looper.loop(Looper.java:132)
09-16 10:20:25.550: VERBOSE/ContactPhotoManager(11691):     at android.os.HandlerThread.run(HandlerThread.java:60)

这篇关于ContactsContract.Directory - 如何返回照片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆