سؤال

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