代码
- ConnectivityManager con=(ConnectivityManager)getSystemService(Activity.CONNECTIVITY_SERVICE);
- boolean wifi=con.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting();
- if(wifi){
- //执行相关操作
- }else{
- Toast.makeText(getApplicationContext(), "当前为非WiFi网络,注意流量哦--", Toast.LENGTH_LONG).show();
- }
权限