现在我现在遇到一些问题:
05-14 16:20:59.355:D / ImageLoader(31397):启动显示图像任务 [content://com.android.contacts/contacts/281/photo_120x120] 05-14 16:20:59.360:D / ImageLoader(31397):从网络加载图像 [content://com.android.contacts/contacts/281/photo_120x120] 05-14 16:20:59.360:D / ImageLoader(31397):在磁盘上缓存映像 [内容://com.android.contacts/contacts/281/photo_120x120]
05-14 16:20:59.445:E / ImageLoader(31397):URI: 内容://com.android.contacts/contacts/281/photo/photo 05-14 16:20:59.445:E / ImageLoader(31397): java.lang.IllegalArgumentException:URI: 内容://com.android.contacts/contacts/281/photo/photo 05-14 16:20:59.445:E / ImageLoader(31397):at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167) 05-14 16:20:59.445:E / ImageLoader(31397):at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137) 05-14 16:20:59.445:E / ImageLoader(31397):at android.content.ContentProviderProxy.query(ContentProviderNative.java:385) 05-14 16:20:59.445:E / ImageLoader(31397):at android.content.ContentResolver.query(ContentResolver.java:417)05-14 16:20:59.445:E / ImageLoader(31397):at android.content.ContentResolver.query(ContentResolver.java:360)05-14 16:20:59.445:E / ImageLoader(31397):at android.provider.ContactsContract $ Contacts.openContactPhotoInputStream(ContactsContract.java:1982) 05-14 16:20:59.445:E / ImageLoader(31397):at android.provider.ContactsContract $ Contacts.openContactPhotoInputStream(ContactsContract.java:2013) 05-14 16:20:59.445:E / ImageLoader(31397):at com.view.widget.ContactDownloader.getStreamFromContent(ContactDownloader.java:26) 05-14 16:20:59.445:E / ImageLoader(31397):at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:88) 05-14 16:20:59.445:E / ImageLoader(31397):at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.downloadImage(LoadAndDisplayImageTask.java:290) 05-14 16:20:59.445:E / ImageLoader(31397):at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryCacheImageOnDisk(LoadAndDisplayImageTask.java:273) 05-14 16:20:59.445:E / ImageLoader(31397):at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:229) 05-14 16:20:59.445:E / ImageLoader(31397):at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:135) 05-14 16:20:59.445:E / ImageLoader(31397):at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 05-14 16:20:59.445:E / ImageLoader(31397):at java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:573) 05-14 16:20:59.445:E / ImageLoader(31397):at java.lang.Thread.run(Thread.java:841)
我尝试在问题564中扩展BaseImageDownloader并覆盖getStreamFromContent(...)方法: https://github.com/nostra13/Android-Universal-Image-Loader/issues/564 同样的:
@Override
protected InputStream getStreamFromContent(String imageUri, Object extra) throws FileNotFoundException {
ContentResolver res = context.getContentResolver();
Uri uri = Uri.parse(imageUri);
if (imageUri.startsWith("content://com.android.contacts/")) {
return ContactsContract.Contacts.openContactPhotoInputStream(res, uri);
} else {
return res.openInputStream(uri);
}
}
但没有成功。
请帮帮我。
谢谢&问候
答案 0 :(得分:0)
我认为你在这里讨论(并解决)了这个问题:Load Contact Image Into Bitmap。作为参考,解决方案是将联系人自身的URI传递给openContactPhotoInputStream(),而不是联系人照片的URI。
答案 1 :(得分:0)
使用下面的代码对我来说工作正常。我希望它也适合你......
public class BaseImageLoaderClass extends BaseImageDownloader {
public BaseImageLoaderClass(Context context) {
super(context);
}
@Override
protected InputStream getStreamFromContent(String imageUri, Object extra)
throws FileNotFoundException {
ContentResolver res = context.getContentResolver();
Uri uri = Uri.parse(imageUri);
if (imageUri.startsWith("content://com.android.contacts/")) {
// return ContactsContract.Contacts.openContactPhotoInputStream(res,
// uri);
return getContactBitmapFromURI(context, uri);
} else {
return res.openInputStream(uri);
}
}
public static InputStream getContactBitmapFromURI(Context context, Uri uri)
throws FileNotFoundException {
InputStream input = context.getContentResolver().openInputStream(uri);
if (input == null) {
return null;
}
return input;
// return BitmapFactory.decodeStream(input);
}
}