Android 如何获取支持的网络类型
Android how to get supported network types
我阅读了很多关于获取当前网络类型的帖子,但我对所有支持的网络类型都感兴趣。有办法得到它们吗?
ConnectivityManager
有这样的方法
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
for (NetworkInfo network : connectivityManager.getAllNetworkInfo()) {
Log.d("Network", "network info: " + network.getType() + " " + network.getTypeName());
}
见http://developer.android.com/reference/android/net/ConnectivityManager.html#getAllNetworkInfo()
Returns connection status information about all network types supported by the device.
也添加到清单中<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
我阅读了很多关于获取当前网络类型的帖子,但我对所有支持的网络类型都感兴趣。有办法得到它们吗?
ConnectivityManager
有这样的方法
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
for (NetworkInfo network : connectivityManager.getAllNetworkInfo()) {
Log.d("Network", "network info: " + network.getType() + " " + network.getTypeName());
}
见http://developer.android.com/reference/android/net/ConnectivityManager.html#getAllNetworkInfo()
Returns connection status information about all network types supported by the device.
也添加到清单中<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>