Here is a convenient method to check whether an Android device is connected to the Internet. Note that not all network has Internet access, for example, we could be further asked to sign-in the Starbucks’ wifi. This method not only checks the connection to a network, but also checks whether this network routes to the Internet.
Add the following permission to the
Then call like this.