private boolean NetWorkStatus() {
boolean netSataus = false;
ConnectivityManager cwjManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cwjManager.getActiveNetworkInfo();

if (cwjManager.getActiveNetworkInfo() != null) {
netSataus = cwjManager.getActiveNetworkInfo().isAvailable();
}

if (!netSataus){
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;
}

更多相关文章

  1. android opengl es--星星,旋涡
  2. android全屏问题
  3. android中进度条和选项卡的使用
  4. android socket通信
  5. android 悬浮按钮
  6. android跳转权限设置页面
  7. Android多点触摸放大缩小图片
  8. 欢迎页,引导页和主页
  9. CentOS 安装 Android

随机推荐

  1. Android - 获取设备信息的工具类( DeviceU
  2. Android之SharePreferences数据存储
  3. android中属性动画 ObjectionAnimation
  4. setScaleType
  5. Python获取android设备cpu和内存占用情况
  6. Android多视图(View)切换
  7. android 实现自由移动的悬浮按钮
  8. Android 判断当前设备是手机还是平板的最
  9. View机制深入学习(三) View中的消息传递及I
  10. Android中SQLite数据库中query或者rawque