Android 开发 - 通过 3G 的互联网连接速度缓慢
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
已解决:端口的一些问题。我将服务器端口从 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
搬到移动数据覆盖更好的地区?
Move to an area with better mobile data coverage?