判断有误网络

public class NetWork { //判断有无网络 public static Boolean isConn(Context context){
        //得到系统服务 ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        //得到网络信息类对象 NetworkInfo info = manager.getActiveNetworkInfo();
        //进行判断 if (info!=null&&info.isAvailable()){
            return true;
        }else{
            return false;
        }

    }

    //没网弹出一个对话框 public static void openProgressDialog(final Context context){
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("提示");
        builder.setMessage("网络出了点小差,是否设置");
        builder.setPositiveButton("设置",new DialogInterface.OnClickListener() {
            @Override public void onClick(DialogInterface dialogInterface, int i) {
                //跳转到系统设置页面-隐士跳转 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);
            }
        });
        builder.setNegativeButton("取消",null);
        builder.create().show();
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值