I am making application in j2me, i am sending data to server

but before that i want to first check that if internet is working or not (it may be from WIFI or GPRS)

有帮助吗?

解决方案

Try to use getResponseCode() and getResponseMessage() methods of HttpConnection API .

其他提示

There's no reliable way to determine if 'the internet is working' other than sending a request to your server. Just because you have a connection to an ISP, it doesn't mean that the ISP has a connection to the internet, or that a packet sent via that connection can reach your server.

The phone might tell you it's not connected, but if you want to know whether you can reach your server when it is connected, send a request and see what happens.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top