我的网址有什么问题,为什么会出现格式错误? 当我尝试加载谷歌图像时它很好。
class RetrieveImage extends AsyncTask<String, Void, Bitmap> {
protected Bitmap doInBackground(String... urls) {
try {
URL url = new URL(urls[0]);
Log.i("url", url + "");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
}
catch (MalformedURLException e) {
System.out.println("The url is not well formed: " + e);
}
catch (IOException e) {
}
return bitmap;
}
继承我的网址
String uri = "http://c200b.trytocode.com/images/1422684074820.jpg";
Log.i("uri", uri);
new RetrieveImage().execute(uri);