Android 联网设置

<uses-permission android:name="android.permission.INTERNET">uses-permission>  
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">uses-permission>  
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE">uses-permission>

网络判断

ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);  
        NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();  
        if(networkInfo == null || !networkInfo.isAvailable())  
        {  
            //当前有可用网络  
        }  
        else   
        {  
            //当前无可用网络  
        } 

 

转载于:https://www.cnblogs.com/moonbear/p/3335036.html

你可能感兴趣的:(Android 联网设置)