网络判断
来源:互联网 发布:turn.js 翻页区域设置 编辑:程序博客网 时间:2024/06/10 01:40
public static boolean isConn(Context context){ boolean bisConnFlag=false; //1.获取网络连接的管理对象 ConnectivityManager conManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); //2.通过管理者对象拿到网络的信息 NetworkInfo network = conManager.getActiveNetworkInfo(); if(network!=null){ //3.网络状态是否可用的返回值 bisConnFlag=network.isAvailable(); } return bisConnFlag; }/** * 如果没有网络 弹出dialog对话框,,,是否进入设置网络的页面 * @param context */public static void showNoNetWorkDlg(final Context context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setIcon(R.mipmap.ic_launcher) // .setTitle("警告")// .setMessage("当前无网络,是否去设置?").setPositiveButton("设置", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // 跳转到系统的网络设置界面 Intent intent = null; // 先判断当前系统版本 if(android.os.Build.VERSION.SDK_INT > 10){// 3.0以上 intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS); }else{ intent = new Intent(); intent.setClassName("com.android.settings", "com.android.settings.WirelessSettings"); } context.startActivity(intent); } }).setNegativeButton("取消", null).show();}
阅读全文
0 0
- 网络判断
- 网络判断
- 判断网络
- 判断网络
- 网络判断
- 判断网络
- 网络判断
- 网络判断
- 网络判断
- 判断网络
- 网络判断
- 判断网络
- 网络判断
- 判断网络
- 网络判断
- 判断网络
- 网络判断
- 网络判断
- Spark基础
- DP练习1:花店橱窗布置
- 图片轮播(首尾无缝+JS节流的应用)
- source insight4.0的使用
- hdu1089 Ignatius's puzzle
- 网络判断
- 在animate执行时如何停止
- java的随机数生成原理
- 第一次作业
- android studio 编译时的报内存错误
- VUE 老项目改造,常用方法说明
- transform实现HTML元素添加固定定位后水平垂直居中
- HDU
- python 接口自动化测试(一)