Android 通用图像加载器和毕加索不加载某些图像URL
我在android应用程序中使用一个列表视图,它有一个文本视图和一个图像视图。 从要显示到imageView中的web服务URL获取。 但是许多图像URL没有加载。我尝试了“安卓通用图像加载器”和“毕加索”下载图像URL。我用我的图像URL尝试了这些API示例应用程序,得到了相同的结果。 图像URL工作正常。所有图像都将在浏览器中打开。 为什么有些图像已加载有些图像未加载?我不明白为什么。Android 通用图像加载器和毕加索不加载某些图像URL,android,universal-image-loader,picasso,imageurl,imagedownload,Android,Universal Image Loader,Picasso,Imageurl,Imagedownload,我在android应用程序中使用一个列表视图,它有一个文本视图和一个图像视图。 从要显示到imageView中的web服务URL获取。 但是许多图像URL没有加载。我尝试了“安卓通用图像加载器”和“毕加索”下载图像URL。我用我的图像URL尝试了这些API示例应用程序,得到了相同的结果。 图像URL工作正常。所有图像都将在浏览器中打开。 为什么有些图像已加载有些图像未加载?我不明白为什么。 感谢您的回答。问题在于您的服务器正在将请求URL更改为mobile,并且移动服务器中不存在图像。强制UIL
感谢您的回答。问题在于您的服务器正在将请求URL更改为mobile,并且移动服务器中不存在图像。强制UIL使用另一个代理应该使服务器不会重定向您的请求 在DisplayImageOptions上尝试使用UIL
Map<String, String> headers = new HashMap<String, String>();
headers.put("User-Agent","");
options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.dummyhotelimage)
.showImageForEmptyUri(R.drawable.dummyhotelimage)
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true)
.extraForDownloader(headers)
.bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(ImageScaleType.EXACTLY)
.build();
ImageLoader.getInstance().init(new ImageLoaderConfiguration.Builder(getActivity()).imageDownloader(new CustomImageDownloader(context)).build());
ImageLoader.getInstance().displayImage(fullImageUrl, holder.img_hotel, options);
Map headers=newhashmap();
headers.put(“用户代理”,“用户代理”);
选项=新建DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.dummyhotelimage)
.showImageForEmptyUri(R.drawable.dummyhotelimage)
.cacheInMemory(真)
.cacheOnDisk(真)
.considerExifParams(真)
.extraForDownloader(标题)
.bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(imageScaleType.Justice)
.build();
ImageLoader.getInstance().init(新的ImageLoaderConfiguration.Builder(getActivity()).imageDownloader(新的CustomImageDownloader(上下文)).build());
ImageLoader.getInstance().displayImage(fullImageUrl、holder.img_hotel、options);
然后创建一个自定义ImageDownloader
public class CustomImageDownaloder extends BaseImageDownloader {
public CustomImageDownaloder(Context context) {
super(context);
}
public CustomImageDownaloder(Context context, int connectTimeout, int readTimeout) {
super(context, connectTimeout, readTimeout);
}
@Override
protected HttpURLConnection createConnection(String url, Object extra) throws IOException {
HttpURLConnection conn = super.createConnection(url, extra);
Map<String, String> headers = (Map<String, String>) extra;
if (headers != null) {
for (Map.Entry<String, String> header : headers.entrySet()) {
conn.setRequestProperty(header.getKey(), header.getValue());
}
}
return conn;
}
}
公共类CustomImageDownaloder扩展了BaseMageDownloader{
公共CustomImageDownaloder(上下文){
超级(上下文);
}
公共CustomImageDownaloder(上下文上下文、int-connectTimeout、int-readTimeout){
超级(上下文、连接超时、读取超时);
}
@凌驾
受保护的HttpURLConnection createConnection(字符串url,对象额外)引发IOException{
HttpURLConnection conn=super.createConnection(url,额外);
映射头=(映射)额外;
如果(标题!=null){
for(Map.Entry头:headers.entrySet()){
conn.setRequestProperty(header.getKey(),header.getValue());
}
}
返回连接;
}
}
来源:问题在于您的服务器正在将请求URL更改为mobile,并且移动服务器中不存在图像。强制UIL使用另一个代理应该使服务器不会重定向您的请求 在DisplayImageOptions上尝试使用UIL
Map<String, String> headers = new HashMap<String, String>();
headers.put("User-Agent","");
options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.dummyhotelimage)
.showImageForEmptyUri(R.drawable.dummyhotelimage)
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true)
.extraForDownloader(headers)
.bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(ImageScaleType.EXACTLY)
.build();
ImageLoader.getInstance().init(new ImageLoaderConfiguration.Builder(getActivity()).imageDownloader(new CustomImageDownloader(context)).build());
ImageLoader.getInstance().displayImage(fullImageUrl, holder.img_hotel, options);
Map headers=newhashmap();
headers.put(“用户代理”,“用户代理”);
选项=新建DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.dummyhotelimage)
.showImageForEmptyUri(R.drawable.dummyhotelimage)
.cacheInMemory(真)
.cacheOnDisk(真)
.considerExifParams(真)
.extraForDownloader(标题)
.bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(imageScaleType.Justice)
.build();
ImageLoader.getInstance().init(新的ImageLoaderConfiguration.Builder(getActivity()).imageDownloader(新的CustomImageDownloader(上下文)).build());
ImageLoader.getInstance().displayImage(fullImageUrl、holder.img_hotel、options);
然后创建一个自定义ImageDownloader
public class CustomImageDownaloder extends BaseImageDownloader {
public CustomImageDownaloder(Context context) {
super(context);
}
public CustomImageDownaloder(Context context, int connectTimeout, int readTimeout) {
super(context, connectTimeout, readTimeout);
}
@Override
protected HttpURLConnection createConnection(String url, Object extra) throws IOException {
HttpURLConnection conn = super.createConnection(url, extra);
Map<String, String> headers = (Map<String, String>) extra;
if (headers != null) {
for (Map.Entry<String, String> header : headers.entrySet()) {
conn.setRequestProperty(header.getKey(), header.getValue());
}
}
return conn;
}
}
公共类CustomImageDownaloder扩展了BaseMageDownloader{
公共CustomImageDownaloder(上下文){
超级(上下文);
}
公共CustomImageDownaloder(上下文上下文、int-connectTimeout、int-readTimeout){
超级(上下文、连接超时、读取超时);
}
@凌驾
受保护的HttpURLConnection createConnection(字符串url,对象额外)引发IOException{
HttpURLConnection conn=super.createConnection(url,额外);
映射头=(映射)额外;
如果(标题!=null){
for(Map.Entry头:headers.entrySet()){
conn.setRequestProperty(header.getKey(),header.getValue());
}
}
返回连接;
}
}
来源:问题在于您的服务器正在将请求URL更改为mobile,并且移动服务器中不存在图像。强制UIL使用另一个代理应该使服务器不会重定向您的请求 在DisplayImageOptions上尝试使用UIL
Map<String, String> headers = new HashMap<String, String>();
headers.put("User-Agent","");
options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.dummyhotelimage)
.showImageForEmptyUri(R.drawable.dummyhotelimage)
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true)
.extraForDownloader(headers)
.bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(ImageScaleType.EXACTLY)
.build();
ImageLoader.getInstance().init(new ImageLoaderConfiguration.Builder(getActivity()).imageDownloader(new CustomImageDownloader(context)).build());
ImageLoader.getInstance().displayImage(fullImageUrl, holder.img_hotel, options);
Map headers=newhashmap();
headers.put(“用户代理”,“用户代理”);
选项=新建DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.dummyhotelimage)
.showImageForEmptyUri(R.drawable.dummyhotelimage)
.cacheInMemory(真)
.cacheOnDisk(真)
.considerExifParams(真)
.extraForDownloader(标题)
.bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(imageScaleType.Justice)
.build();
ImageLoader.getInstance().init(新的ImageLoaderConfiguration.Builder(getActivity()).imageDownloader(新的CustomImageDownloader(上下文)).build());
ImageLoader.getInstance().displayImage(fullImageUrl、holder.img_hotel、options);
然后创建一个自定义ImageDownloader
public class CustomImageDownaloder extends BaseImageDownloader {
public CustomImageDownaloder(Context context) {
super(context);
}
public CustomImageDownaloder(Context context, int connectTimeout, int readTimeout) {
super(context, connectTimeout, readTimeout);
}
@Override
protected HttpURLConnection createConnection(String url, Object extra) throws IOException {
HttpURLConnection conn = super.createConnection(url, extra);
Map<String, String> headers = (Map<String, String>) extra;
if (headers != null) {
for (Map.Entry<String, String> header : headers.entrySet()) {
conn.setRequestProperty(header.getKey(), header.getValue());
}
}
return conn;
}
}
公共类CustomImageDownaloder扩展了BaseMageDownloader{
公共CustomImageDownaloder(上下文){
超级(上下文);
}
公共CustomImageDownaloder(上下文上下文、int-connectTimeout、int-readTimeout){
超级(上下文、连接超时、读取超时);
}
@凌驾
受保护的HttpURLConnection createConnection(字符串url,对象额外)引发IOException{
HttpURLConnection conn=super.createConnection(url,额外);
映射头=(映射)额外;
如果(标题!=null){
for(Map.Entry头:headers.entrySet()){
conn.setRequestProperty(header.getKey(),header.getValue());
}
}
返回连接;
}
}
来源:问题在于您的服务器正在将请求URL更改为mobile,并且移动服务器中不存在图像。强制UIL使用另一个代理应该使服务器不会重定向您的请求 在DisplayImageOptions上尝试使用UIL
Map<String, String> headers = new HashMap<String, String>();
headers.put("User-Agent","");
options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.dummyhotelimage)
.showImageForEmptyUri(R.drawable.dummyhotelimage)
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true)
.extraForDownloader(headers)
.bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(ImageScaleType.EXACTLY)
.build();
ImageLoader.getInstance().init(new ImageLoaderConfiguration.Builder(getActivity()).imageDownloader(new CustomImageDownloader(context)).build());
ImageLoader.getInstance().displayImage(fullImageUrl, holder.img_hotel, options);
Map headers=newhashmap();
headers.put(“用户代理”,“用户代理”);
选项=新的DisplayImageOptions.B