Android之检查网络是否可用(跳转网络设置页面)
2013-06-19 10:28
501 查看
private boolean NetWorkStatus() { ConnectivityManager cwjManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); // cwjManager.getActiveNetworkInfo(); boolean netSataus = true; if (cwjManager.getActiveNetworkInfo() != null) { netSataus = cwjManager.getActiveNetworkInfo().isAvailable(); Toast.makeText(this, "网络已经打开", Toast.LENGTH_LONG).show(); } else { Builder b = new AlertDialog.Builder(this).setTitle("没有可用的网络") .setMessage("是否对网络进行设置?"); b.setPositiveButton("是", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Intent mIntent = new Intent("/"); ComponentName comp = new ComponentName( "com.android.settings", "com.android.settings.WirelessSettings"); mIntent.setComponent(comp); mIntent.setAction("android.intent.action.VIEW"); // 如果在设置完成后需要再次进行操作,可以重写操作代码,在这里不再重写 startActivityForResult(mIntent, 0); } }).setNeutralButton("否", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).show(); } return netSataus; }
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
相关文章推荐
- Android判断网络是否连接,跳转到设置页面以及判断连接的是什么网络
- Android判断网络是否连接,跳转到设置页面以及判断连接的是什么网络
- android 检查网络是否可用,如果不可用弹出设置,让用户改变
- Android中检查网络连接状态的变化无网络时跳转到设置界面
- android:检查系统是否开启消息通知权限,app应用点击开启通知时跳转到app详情页面开启权限
- Android wiki:04.ConnectivityManager检查是否有可用网络
- 检查网络是否可用(Android)
- Android判断网络是否可用,调用系统网络设置
- 无废话Android之smartimageview使用、android多线程下载、显式意图激活另外一个activity,检查网络是否可用定位到网络的位置、隐式意图激活另外一个activity、隐式意图的配置,自定义隐式意图、在不同activity之间数据传递(5)
- Android中检查网络连接状态的变化,无网络时跳转到设置界面
- Android 检查手机网络是否可用
- android中 检查 网络连接状态的变化,无网络时跳转到设置界面
- (转)android中 检查网络连接状态的变化,无网络时跳转到设置界面
- 判断是否有网络,如果没有网络,弹出对话框,然后可以跳转到设置页面
- android中 检查 网络连接状态的变化,无网络时跳转到设置界面
- Android检查当前网络状态是否可用并
- android中 检查 网络连接状态的变化,无网络时跳转到设置界面
- 检查Android网络连接是否可用
- [Android] 检查网络是否可用
- android检查网络连接状态的变化,无网络时跳转到设置界面