I able to check Mobile is connected to wifi router but how check router accessing internet or not ?if phone is connected to router then it returns true but not check for internet access plz help...
public boolean isInternetAvailable() {
ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null)
{
for (int i = 0; i < info.length; i++)
// if (info[i].(info[i].getState() == NetworkInfo.State.CONNECTED)
if(info[i]!=null && info[i].isAvailable() && info[i].isConnected())
{
try {
if (InetAddress.getByName("https://www.google.co.in").isReachable(3000))
{
return true;
}
else
{
return false;
// host not reachable
}
} catch (IOException e) {
e.printStackTrace();
}
Log.i("Network Info", info[i].toString());
return true;
}
}
return false;
}
return false;
}
}