【发布时间】:2011-01-12 12:27:18
【问题描述】:
public Object fetch(String address) throws MalformedURLException,
IOException {
URL url = new URL(address);
Object content = url.getContent();
return content;
}
private Drawable ImageOperations(Context ctx, String url) {
try {
InputStream is = (InputStream) this.fetch(url);
Drawable d = Drawable.createFromStream(is, "src");
return d;
} catch (MalformedURLException e) {
return null;
} catch (IOException e) {
return null;
}
catch (Exception e)
{
return null;
}
}
try {
Drawable a =ImageOperations(this,"url"); imgView.setImageDrawable(a);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
这可行,但在极少数情况下,由于“SocketException:协议不支持地址系列”,应用程序会冻结。有没有什么办法解决这一问题?谢谢
【问题讨论】: