gpt4 book ai didi

java - ImageLoader:连接超时

转载 作者:行者123 更新时间:2023-12-02 12:00:20 30 4
gpt4 key购买 nike

我正在使用 ImageLoader 从互联网加载图像。但我收到错误消息“E ImageLoader:连接超时”,跟踪是:

05-29 16:39:02.994 9988 10417 E ImageLoader: connect timed out 05-29 16:39:02.994 9988 10417 E ImageLoader: java.net.SocketTimeoutException: connect timed out 05-29 16:39:02.994 9988 10417 E ImageLoader: at java.net.PlainSocketImpl.socketConnect(Native Method) 05-29 16:39:02.994 9988 10417 E ImageLoader: at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:334) 05-29 16:39:02.994 9988 10417 E ImageLoader: at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:196) 05-29 16:39:02.994 9988 10417 E ImageLoader: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) 05-29 16:39:02.994 9988 10417 E ImageLoader: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356) 05-29 16:39:02.994 9988 10417 E ImageLoader: at java.net.Socket.connect(Socket.java:605) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.internal.Platform.connectSocket(Platform.java:113) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.Connection.connectSocket(Connection.java:196) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.Connection.connect(Connection.java:172) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:247) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:480) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:428) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:544) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromNetwork(BaseImageDownloader.java:117) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:88) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.getImageStream(BaseImageDecoder.java:98) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:74) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:265) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:238) 05-29 16:39:02.994 9988 10417 E ImageLoader: at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:136) 05-29 16:39:02.994 9988 10417 E ImageLoader: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 05-29 16:39:02.994 9988 10417 E ImageLoader: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 05-29 16:39:02.994 9988 10417 E ImageLoader: at java.lang.Thread.run(Thread.java:761) 05-29 16:39:02.995 9988 9988 D TweetAdapter: onLoadingFailed, uri is https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg, failReason 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) {

}
});

我尝试了另一个网址,例如“https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg ”,但同样的错误再次发生。

谁能帮助我?

最佳答案

解决办法:我的手机无法访问这两个需要国际互联网权限的网址,但我的电脑可以访问

关于java - ImageLoader:连接超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47310495/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com