2
我已经创建了一个android应用程序,其中图像从给定url加载。当我直接传递url时,图像正在加载。但是当我在一个字符串变量中传递该变量并传递该变量时,图像不会被加载。我的代码如下。为什么图像不是从android应用程序的url加载?
private Drawable ImageOperations(String url, String saveFilename) {
try {
String realImageUrl=url+"? email="+Constants.email+"&proc_date="+Constants.proc_date+"&access_key="
+Constants.ACCESS_KEY+"&version=1.00";
String newUrl=realImageUrl.replace("https", "http");
InputStream is = (InputStream) this.fetch(newUrl);
Log.e("https,SubString http: ",realImageUrl+","+ a);
Drawable d = Drawable.createFromStream(is, "src");
return d;
} catch (MalformedURLException e) {
return null;
} catch (IOException e) {
return null;
}
}
public Object fetch(String address) throws MalformedURLException,
IOException {
URL url = new URL(address);
Object content = url.getContent();
return content;
}
此代码无效。我的新网址是newUrl。当我在我的日志中打印newUrl并直接给该URL而不是newUrl时,图像正在加载。
1.请详细说明,工作的代码和没有代码的代码(显示两者的代码段)之间的确切**区别是什么。 2.当你触发获取图像时,logcat会说什么? – vArDo 2012-07-14 21:41:32