从 J2ME 重新连接到 GPRS
我有一个小问题。我开发了一个 midlet 应用程序,通过互联网调用一些网络服务。我使用的是具有 GPRS 连接的手机。一段时间它按照我想要的方式运行,运行应用程序,通过 GPRS 调用 Web 服务,返回结果,再次调用 Web 服务,等等。
但是,假设我调用了网络服务,在应用程序返回我需要的结果后,我将其搁置了一段时间。下次我继续访问网络服务时,应用程序需要一段时间才能通过 GPRS 连接。在诺基亚,它在方框中标有G。在东南部,它标有一个发光的地球仪。盒子中的“G”或发光的地球仪会在一段时间后出现或根本不会出现,但应用程序仍在尝试连接到互联网。
它来自我的应用程序还是来自手机?我能否知道 [或应用程序知道] 目前应用程序尝试连接 GPRS 已准备就绪?
非常感谢您的回复...
I have a little problem. I have developed a midlet application that call some webservices through internet. I'm using cell phones with GPRS connection. For some time it runs as I wanted, run the apps, call the webservices through the GPRS, it returns the result, call the webservices again, and so on.
But say, I call the webservices and after the apps return the result I needed, I left it for a while. The next time I continue to access the webservices, the apps takes a while to connect through the GPRS. In nokia, it is marked with a G in a box. In SE it is marked with a glowing globe. This 'G' in the box or the glowing globe will appear after a while or won't appear at all, but the apps is still trying to connect to the internet.
Does it come from my apps or it come from the cell phone? And could I know [or the apps knows] that at the moment the apps tries to connect the GPRS is ready?
Thanks a lot for your responses...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遗憾的是,Java ME(即 J2ME)中没有任何内容可以控制设备是否连接。您所能做的就是尝试连接。
不过,请确保您正确关闭了所有连接。包括 HttpConnection 对象,而不仅仅是输入/输出流。
There is nothing in Java ME (i.e. J2ME) that can control whether or not the device is connected, unfortunately. All you can do is try to connect.
Make sure you are properly closing all your connections, though. Including the HttpConnection object, not just the input/output streams.