The android.os.NetworkOnMainThreadException is a runtime exception that is thrown when an application attempts to perform a networking operation on the main thread.
To check for internet access on Android, you can use the isReachable() method of the InetAddress class.