-2

I am facing the issue,

Wifi is connected but internet is not there.

How to check that??

Please somebody help.

Aman Jham
  • 478
  • 6
  • 18

2 Answers2

0

You can use ConnectivityManager to detect it:

WifiManager wm = (WifiManager) Context.getSystemService(WIFI_SERVICE);
WifiInfo niWifi = wm.getConnectionInfo();
SupplicantState supState = niWifi.getSupplicantState();
if(supState == SupplicantState.COMPLETED) {
    // internet is working
}
Giorgio Antonioli
  • 15,771
  • 10
  • 45
  • 70
-1

I'm not 100% sure, but I think that other than checking your Wifi interface if it is up and running, you can't actually know if you are connected to Internet. If your need is just to check if everything is up and running, you could try to retrieve a page (ex: www.google.com ) and be prepared to catch an exception if it's going to fail.

Feel free to tell me I'm an idiot ^_^"

FrancescoC
  • 1,058
  • 10
  • 19