How to check is the device connected to internet or not in Android

With this simple snippet, we can check is the device is connected to internet or not:

private boolean isConnected(){
        ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
        return activeNetworkInfo != null && activeNetworkInfo.isConnected();

So this “isConnected()” returns true if it’s connected, otherwise it returns false.

Getting boored? Why not playing a game?

Power Block

Tiki Solitaire

Pet Connect

Cake Shop

Jewels Blitz 3

Forest Match

Bike Racing


Solitaire Swift

Bubble Shooter Classic HD

Black and white snake

Leave a Reply

Your email address will not be published. Required fields are marked *