2015-12-14 65 views

回答

1

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()

返回有關設備支持的所有類型的網絡連接狀態信息。

也增加了體現<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

相關問題