내 응용 프로그램에서 URL에서 가져 오는 이미지를 다운로드하고 있습니다. 여기서 문제는 너무 오래 걸린다는 것입니다. 이미지는 압축되고 단지 9km에 불과합니다. 50 개를 다운로드 중이므로 500kByte의 이미지가 앱에서 다운로드되고 있다고 가정 해 보겠습니다. 이것은 꽤 빠를 것입니다, 맞습니까? 음, 그렇지 않습니다. 로드 될 때까지 20 초 동안 가끔씩 기다리고 있습니다. 너무 오래 걸리는 이유는 무엇입니까? 나는 이미지를 다운로드하는 아주 쉬운 방법이있다. 여기가이미지 다운로드 시간을 단축하십시오
int downloadingImages = getDownloadImageCount();
System.out.println(downloadingImages);
if(downloadingImages == 0){
for(int c = downloadingImages; c < 50; c++){
try{
bitmapArr[c] = getBitmapFromURL(imageURLArr[c]);
setDownloadImageCount(50);
publishProgress(c);
} catch (FileNotFoundException f1){
Log.v("FileNotFoundException", "Bitmap konnte nicht geladen werden");
} catch(NullPointerException e){
} catch (IllegalStateException ie){
}
setDownloadImageCount(50);
}
}
입니다 이것은 getBitmapFromUrl 기능 내 말은
public static Bitmap getBitmapFromURL(String src) throws FileNotFoundException {
try {
//Downloading the image
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
try{
//Saving the image to a bitmap and return it
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
//Catch Exception if file not found
} catch(FileNotFoundException ffe){
Log.v("FileNotFoundException", "getBitmapFromURLMethod");
return null;
}
//Catch Exception if error at input and output
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
은 너무 오래 거기에 무엇을 취하고 무엇입니까? 어떻게 속도를 높일 수 있습니까? 나중에 카힐을 이미지에 사용 하겠지만, 여전히 ... 나는 500kbs이고 너무 오래 걸린다는 것을 의미합니다. 왜 그런가요?
휠을 다시 시도하지 마십시오. http://square.github.io/picasso/ – Budius
타임 라인을 여러 줄로 길게 입력하십시오. 이것은 너무 오래 걸리는 것을 알려줄 수 있습니다. 서버와 연결하는 것도 시간이 많이 소요되는 과정입니다. 따라서 연결 설정에 시간이 걸리거나 다운로드 중인지 확인하십시오. –
유니버설 이미지 로더를 사용할 수도 있습니다. https://github.com/nostra13/Android-Universal-Image-Loader –