标签:
ConnectivityManager manager = (ConnectivityManager) this .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = manager.getActiveNetworkInfo(); if (info != null && info.isAvailable()) { Toast.makeText(this, "网络可用", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(this, "网络不可用", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.setAction(Settings.ACTION_WIFI_SETTINGS); this.startActivity(intent); }
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
标签:
原文地址:http://www.cnblogs.com/linson0116/p/4977713.html