app/src/main/java/com/voices/utils/AppUtils.java
/**
     * Method to check internet connection
     *
     * @param mContext
     * @return boolean
     */
Method to check internet connection
@param mContext
@return boolean
Method to check internet connection @param mContext @return boolean
public static boolean checkNetworkConnection(Context mContext) {
        ConnectivityManager connec =
                (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
        if (connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTED ||
                connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTING ||
                connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTING ||
                connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTED) {
            return true;
        } else if (
                connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.DISCONNECTED ||
                        connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.DISCONNECTED) {
            return false;
        }
        return false;
    }
public static boolean checkNetworkConnection ( Context mContext ) { ConnectivityManager connec = ( ConnectivityManager ) mContext . getSystemService ( Context . CONNECTIVITY_SERVICE ) ; if ( connec . getNetworkInfo ( 0 ) . getState ( ) == android . net . NetworkInfo . State . CONNECTED || connec . getNetworkInfo ( 0 ) . getState ( ) == android . net . NetworkInfo . State . CONNECTING || connec . getNetworkInfo ( 1 ) . getState ( ) == android . net . NetworkInfo . State . CONNECTING || connec . getNetworkInfo ( 1 ) . getState ( ) == android . net . NetworkInfo . State . CONNECTED ) { return true ; } else if ( connec . getNetworkInfo ( 0 ) . getState ( ) == android . net . NetworkInfo . State . DISCONNECTED || connec . getNetworkInfo ( 1 ) . getState ( ) == android . net . NetworkInfo . State . DISCONNECTED ) { return false ; } return false ; }
Method to check internet connection
 @param mContext
 @return boolean
Method to check internet connection @param mContext @return boolean
// get Connectivity Manager object to check connection // Check for network connections