I want to check programmatically whether there is an internet connection in Android phone/emulator. So that once I am sure that an internet connection is present then I\'ll
this code must be run in background thread
fun hasActiveInternetConnection(): Boolean { return try { val ipAddr: InetAddress = InetAddress.getByName("google.com") !ipAddr.equals("") } catch (e: java.lang.Exception) { false } }