Search code examples
androidandroid-networking

Android how to get supported network types


I read many posts about getting the current network type, but i'm interested in all supported network types. Is there a way to get them?


Solution

  • ConnectivityManager has methods for this

    ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
    
    for (NetworkInfo network : connectivityManager.getAllNetworkInfo()) {
        Log.d("Network", "network info: " + network.getType() + " " + network.getTypeName());
    }
    

    see http://developer.android.com/reference/android/net/ConnectivityManager.html#getAllNetworkInfo()

    Returns connection status information about all network types supported by the device.

    Also add to manifest <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>