Android 应用程序可在 WiFi、调试模式或模拟器上运行,而不是在蜂窝网络上运行

发布于 2024-09-08 17:14:28 字数 1295 浏览 2 评论 0原文

我有一个 Android 应用程序,可以解析一些 HTML、下载图像并显示它。我正在使用 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 有关,但我不知道如何弄清楚发生了什么事。我希望 Android 上有类似 Wireshark 的东西。我已将我的代码提供给 T-Mobile 上的一位朋友(使用 G1)和 Sprint 上的一位朋友(使用 EVO)。我在 Verizon 上有 Droid Eris。

I have an android application that parses some HTML, downloads an image, and displays it. I'm using an AsyncTask to do the HTML parsing and image downloading, but that shouldn't be relevant. I never have a problem when I'm on WiFi on my phone, when I'm using the Eclipse debugger on my phone, or when I'm using the emulator. When I have my phone on the cell network (even with pretty good reception), the image sometimes fails to display.

I'm having a hard time figuring out what is wrong, since the problem cannot be reproduced in the debugger. Does anyone have any idea what could be wrong?

Thanks!

Update: I have narrowed it down to the image downloading function. This way my original code:

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;
}

I have also tried using the code from this tutorial, but the same bug showed up.

http://www.devx.com/wireless/Article/39810/1954

At this point I think it must have to do with Verizon, but I'm not sure how to figure out what's going on. I wish there was something like Wireshark for Android. I've given my code to a friend of mine on T-Mobile with the G1 and a friend on Sprint with the EVO. I have the Droid Eris on Verizon.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最近可好 2024-09-15 17:14:28

那是什么载体?我记得 T-Mobile 总是通过他们自己的代理路由 http 流量,这刷新有点慢,并且存在一些问题,特别是当数据低于一定大小时 - 我相信是 64KB。

请参阅此帖子:http://groups。 google.com/group/android-developers/browse_frm/thread/48e84811764da1cb/7f052a903314b2b4?hl=zh-CN

What carrier is that? I remember that T-Mobile always routed http traffic through their own proxy which is a bit slow to refresh, and there were some issues, particularly when the data was under a certain size - 64KB, I believe.

See this thread: http://groups.google.com/group/android-developers/browse_frm/thread/48e84811764da1cb/7f052a903314b2b4?hl=en

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文