Search code examples
androidandroid-wifihostreachabilityandroid-networking

How to detect host reachability in android?


In IOS we have implemented using Reachability framework which provided by apple, In Android We need to find whether active internet connection is available are not. Actually We need find whether Wi-fi connected with active internet connection or not, We have tried lot of ways but we need to deduct instantly. In this case we should find out host reachability status of internet connection. We have tried this below link .

It was taken some time for the response, But we need to get instant response to finish the requirement. We need to solve the case, device connected with Wi-Fi but doesn't have internet connection. If anyone know the solution help us. Thanks in advance.


Solution

  • In Android, you can subscribe to get a notification when it WiFi has connected. This is as instant as you are going to get.

    ConnectivityManager will also allow you to poll to see if WiFi is available, but it's much better (and more battery friendly) to get an event.

    See here for details