当互联网连接可用时,黑莓会收到通知。
有什么方法可以知道黑莓设备中的网络是否已连接。我有以下代码,但它一直在等待,直到网络超时。
int rc = connection.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
throw new IOException("HTTP response code: " + rc);
}
还有什么办法吗。
is there any way to know whether the net is connected or not in a blackbery device .I have the following code but it was waiting till the network timed out.
int rc = connection.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
throw new IOException("HTTP response code: " + rc);
}
Is there any other way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有几个API用于获取网络信息:
There are several API for getting network info:
该问题的标题与问题正文的含义不同。根据标题,您可以使用RadioStatusListener 接口在网络启动时收到通知,该接口定义了一个networkStarted() 函数。然后,您可以使用 Coldice 建议的检查来确保当前网络支持数据传输。
RadioStatusListner JavaDocs
The title of this question has a different meaning than the body of the question. Based on the title, you can be notified when the network starts by using the RadioStatusListener interface, which defines a networkStarted() function. You could then use the checks that coldice recommends to make sure that the current network supports data transfer.
RadioStatusListner JavaDocs