Android 判断网络并打开设置界面

以前做过判断网络的功能,但未实现打开设置界面功能,因为2.3.3版本以后的直接跳转到是设置页面,如图:

而以前的版本需要跳转到页面是:如图

最近在eoe论坛发现有人发出了关于此类的源码,http://www.eoeandroid.com/thread-255505-1-1.html 特将跳转页面代码摘抄出来如下

/*
     * 打开设置网络界面
     */
    public static void setNetworkMethod(final Context context) {
        // 提示对话框
        AlertDialog.Builder builder = new Builder(context);
        builder.setTitle("网络设置提示")
                .setMessage("网络连接不可用,是否进行设置?")
                .setPositiveButton("设置", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub
                        Intent intent = null;
                        
                        if (android.os.Build.VERSION.SDK_INT > 10) {
                            intent = new Intent(
                                    android.provider.Settings.ACTION_WIRELESS_SETTINGS);
                        } else {
                            intent = new Intent();
                            ComponentName component = new ComponentName(
                                    "com.android.settings",
                                    "com.android.settings.WirelessSettings");
                            intent.setComponent(component);
                            intent.setAction("android.intent.action.VIEW");
                        }
                        context.startActivity(intent);
                    }
                })
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub
                        dialog.dismiss();
                    }
                }).show();
    }

源代码链接http://pan.baidu.com/share/link?shareid=682097&uk=3909095065

原文地址:https://www.cnblogs.com/sishuiliuyun/p/3101315.html