我正在使用ImageLoader从Internet加载图像。但是我收到错误消息“ E ImageLoader:连接超时”,跟踪为:
05-29 16:39:02.994 9988 10417 E ImageLoader:连接超时05-29
16:39:02.994 9988 10417 E ImageLoader:
java.net.SocketTimeoutException:连接超时05-29 16:39:02.994
9988 10417 E ImageLoader:在
java.net.PlainSocketImpl.socketConnect(本机方法)05-29
16:39:02.994 9988 10417 E ImageLoader:在
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:334)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:196)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356)05-29
16:39:02.994 9988 10417 E ImageLoader:在
java.net.Socket.connect(Socket.java:605)05-29 16:39:02.994 9988
10417 E ImageLoader:在
com.android.okhttp.internal.Platform.connectSocket(Platform.java:113)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.android.okhttp.Connection.connectSocket(Connection.java:196)05-29
16:39:02.994 9988 10417 E ImageLoader:在
com.android.okhttp.Connection.connect(Connection.java:172)05-29
16:39:02.994 9988 10417 E ImageLoader:在
com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.android.okhttp.OkHttpClient $ 1.connectAndSetOwner(OkHttpClient.java:130)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:247)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:480)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:428)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:544)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromNetwork(BaseImageDownloader.java:117)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:88)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.nostra13.universalimageloader.core.decode.BaseImageDecoder.getImageStream(BaseImageDecoder.java:98)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:74)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:265)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:238)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:136)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:607)
05-29 16:39:02.994 9988 10417 E ImageLoader:在
java.lang.Thread.run(Thread.java:761)05-29 16:39:02.995 9988 9988 D
TweetAdapter:onLoadingFailed,uri是
https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg,
fail原因IO_ERROR
这是我的代码:
private DisplayImageOptions mOptions;
mOptions = new DisplayImageOptions.Builder()
.showImageForEmptyUri(R.mipmap.ic_launcher)
.showImageOnFail(R.mipmap.ic_launcher)
.cacheInMemory(true)
.cacheOnDisk(true)
.build();
mConfig = new ImageLoaderConfiguration.Builder(context)
.defaultDisplayImageOptions(mOptions)
.discCacheSize(50 * 1024 * 1024)
.discCacheFileCount(100)
.writeDebugLogs().build();
ImageLoader.getInstance().init(mConfig);
ViewHolder的定义是:
private static class ViewHolder {
ImageView imageButtonSender;
TextView textViewSenderUserName;
TextView textViewSenderContent;
FrameLayout frameLayoutImages;
LinearLayout linearLayoutCommentContent;
}
在适配器的“ getView”函数中,我将此函数称为:
ImageLoader.getInstance().loadImage("https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQW0S4wK02z4QilNvGE9YFtoJDJtbTsoZavc3INxbD9ZvdRgfxy",
new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
Log.d(TAG, "onLoadingFailed, uri is " + imageUri + ", failReason " + failReason.getType());
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
Log.d(TAG, "onLoadingComplete imageUri " + imageUri);
holder.imageButtonSender.setImageBitmap(loadedImage);
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
我尝试了另一个URL,例如“ https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg”,但是再次发生相同的错误。
谁能帮我 ?
最佳答案
解决方案:我的手机无法访问需要国际互联网许可的这两个URL,但是我的计算机可以访问