Code example for NetworkInfo

Methods: isConnectedisRoaming

0
 
    public boolean isOnline() 
    { 
        ConnectivityManager connectivityManager = ( ConnectivityManager ) context.getSystemService( Context.CONNECTIVITY_SERVICE );
        NetworkInfo info = connectivityManager.getActiveNetworkInfo();
        if ( info == null || !info.isConnected() ) {
            return false; 
        } 
        if ( info.isRoaming() ) {
            return roaming;
        } 
        return true; 
    } 
 
    public static enum ConnectivityState 
    { 
 
        WIFI,
        MOBILE,
        OFFLINE
Contextual code suggestions in your IDE  Get Codota for Java