Android 开发 - 通过 3G 的互联网连接速度缓慢

发布于 2024-10-08 06:29:15 字数 807 浏览 1 评论 0原文

我正在使用 Android/Rails 开发客户端/服务器应用程序并通过 REST Json 进行通信

当我通过模拟器测试我的应用程序时,一切正常。 此外,当我在手机上部署该应用程序并且WIFI开启时,它可以正常工作并且速度也不错。

但是当我断开 WIFI 并使用 3G 连接时,手机变得令人难以置信的慢,并且需要几分钟才能从服务器获得一个 JSON 响应。

我调试了一下,问题似乎是 HTTPClient,它的执行方法需要很长时间。

其他具有网络访问权限的应用程序运行良好。

有什么建议吗?

HTC Magic 
Android 1.6

我的Http连接代码:

HttpClient client = new DefaultHttpClient();
        HttpGet get = new HttpGet("URL");
        try {
            client.execute(get);
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

I'm developing a Client/Server Application with Android/Rails and Communication via REST Json

When I'm testing my App via Emulator, all works fine.
Also when I deploy the app on my phone with WIFI on it works and the speed is ok.

But when I disconnect from WIFI and use the 3G connection, the phone becomes incredible Slow and it takes Minutes du get one JSON Response from the Server.

I'ved debug a little bit and the Problem seems to be the HTTPClient, which execute Method takes ulta long.

Other Apps with Network Access are working perfectly.

Any suggestions what to do?

HTC Magic 
Android 1.6

My Http Connection Code:

HttpClient client = new DefaultHttpClient();
        HttpGet get = new HttpGet("URL");
        try {
            client.execute(get);
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

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

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

发布评论

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

评论(2

罗罗贝儿 2024-10-15 06:29:15

已解决:端口的一些问题。我将服务器端口从 3000 更改为 80,效果很好。感谢您的评论,这是很棒的提示:)。
感谢克里斯·斯特拉顿

SOLVED: Some Problems with the Port. I changed my Server Port from 3000 to 80 and it works just fine. Thanks for the Comment, that was the great Hint :).
Thanks to Chris Stratton

泪冰清 2024-10-15 06:29:15

搬到移动数据覆盖更好的地区?

Move to an area with better mobile data coverage?

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