留神要添加权限公海赌船网址

ConnectivityManager connectivityManager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

        if(networkInfo==null){
            Toast.makeText(this,"没有可用网络",Toast.LENGTH_SHORT).show();
        }
        else if(networkInfo.getType()==ConnectivityManager.TYPE_WIFI){
            Toast.makeText(this,"wifi网络",Toast.LENGTH_SHORT).show();
        }
        else if(networkInfo.getType()==ConnectivityManager.TYPE_MOBILE){
            Toast.makeText(this,"手机网络",Toast.LENGTH_SHORT).show();
        }

专注要添加权限:

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

 

相关文章