我有一个解析一些 HTML、下载图像并显示它的 android 应用程序。我正在使用一个AsyncTask
来进行 HTML 解析和图像下载,但这不应该是相关的。当我在手机上使用 WiFi、在手机上使用 Eclipse 调试器或使用模拟器时,我从来没有遇到过问题。当我将手机连接到蜂窝网络时(即使接收效果很好),图像有时无法显示。
我很难找出问题所在,因为无法在调试器中重现该问题。有谁知道可能出了什么问题?
谢谢!
更新:我已将其范围缩小到图像下载功能。这样我的原始代码:
private Bitmap downloadImage(String url) {
Bitmap image = null;
debug = "";
try {
URL image_url = new URL(url);
HttpURLConnection image_connection = (HttpURLConnection) image_url
.openConnection();
image_connection.connect();
InputStream image_stream = image_connection.getInputStream();
debug = image_stream.available()+"";
image = BitmapFactory.decodeStream(image_stream);
} catch (Exception e) {
Log.e("downloadImage", "Exception: "+e.getMessage());
}
return image;
}
我也尝试过使用本教程中的代码,但出现了同样的错误。
http://www.devx.com/wireless/Article/39810/1954
在这一点上,我认为这一定与 Verizon 有关,但我不确定如何弄清楚发生了什么。我希望有类似 Wireshark for Android 的东西。我已经将我的代码提供给了我在 T-Mobile 上使用 G1 的朋友和在 Sprint 上使用 EVO 的朋友。我在 Verizon 上有 Droid Eris。