안녕하세요 ^^ 구글링해서 서버에서 이미지를 가져오는 코드를 쉽게 찾긴했는데
어떤 이미지는 되고 어떤이미지는 안되더라고요.. 코드가 잘못된건가요? 아니면 원래
이미지 제한이 있는건가요?
package com.example.downloadimg;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ImageView;
public class MainActivity extends Activity {
ImageView imView;
String imgUrl = "http://어쩌고 저쩌고";
Bitmap bmImg;
back task;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
task = new back();
imView = (ImageView) findViewById(R.id.imageView1);
task.execute(imgUrl+"img1");
}
private class back extends AsyncTask<String, Integer,Bitmap>{
@Override
protected Bitmap doInBackground(String... urls) {
// TODO Auto-generated method stub
try{
URL myFileUrl = new URL(urls[0]);
HttpURLConnection conn = (HttpURLConnection)myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bmImg = BitmapFactory.decodeStream(is);
}catch(IOException e){
e.printStackTrace();
}
return bmImg;
}
protected void onPostExecute(Bitmap img){
imView.setImageBitmap(bmImg);
}
}
}
예를 들어서 http://imgnews.naver.net/image/123/2015/11/11/1447225574_99_20151111161204.jpg?type=w540
위에 저 주소는 되는데 옆에 이주소는 안되네요 http://cfile6.uf.tistory.com/image/123C0E284B73BD8228BDB0
지금 다른주소도 계속 시도해보는데 안되는 이미지가 더 많은것같네요;;;
고수님들 왜죠?