Code example for NetworkInfo

Methods: getDetailedState, getType

0
 
        String state = "";
/*Log.d("tag", "type : " + networkInfo.getType()); 
Log.d("tag", "subtype : " + networkInfo.getSubtype()); 
Log.d("tag", "subtypeName : " + networkInfo.getSubtypeName());*/ 
        if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
            state = networkInfo.getState().toString();
        } else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
            state = networkInfo.getDetailedState().toString();
        } 
 
        return state;
    } 
}