2

有什么方法可以知道网络是否在黑莓设备中连接。我有以下代码,但它一直在等待网络超时。

int rc = connection.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
 throw new IOException("HTTP response code: " + rc);
}

有没有其他办法。

4

2 回答 2

4

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

于 2009-09-01T12:31:05.600 回答
3

有几个 API 用于获取网络信息:

RadioInfo.isDataServiceOperational();
CoverageInfo.isOutOfCoverage();
WLANInfo.getWLANState();
于 2009-09-01T12:14:29.053 回答