If you want to check if your device is connected to the internet, you would need to have the permission below, to check the network statue.
Then you create a ConnectivityManager Object to retrieve Network information.
Hope you find it useful. If you have a better way to check if the device is connected to the internet. Please leave me a message, so that I can improve my code =).