简体   繁体   中英

Check if internet is working or not in j2me

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)

尝试使用HttpConnection API的getResponseCode()getResponseMessage()方法。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM