zoukankan      html  css  js  c++  java
  • (三十二)工具方法:如何判断是否有网络/如何调用系统设置界面

    (1)如何判断是否有网络

        /**
         * 判断是否有网络
         * @return
         */
        private boolean isNetWorkConnected(Context ctx) {
            // TODO Auto-generated method stub
            ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(CONNECTIVITY_SERVICE);
            NetworkInfo info = cm.getActiveNetworkInfo();
            Boolean result = false;
            if (info != null && info.isConnected()) {
                result = true;
            } else {
                result = false;
            }
            return result;
        }

    (2)/如何调用系统设置界面

        /**
         * 
         * 方法一:进入系统设置界面
         * 
         */
        private void setSystemSetting1() {
            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");
                }
              startActivity(intent);
        }

    /**
    方法2:进入系统设置界面
    */

    public void setSystemSetting2() {
    // 点击网络设置按钮,进入系统设置
    Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

    }




  • 相关阅读:
    ping与telnet的区别
    TCP连接的建立与关闭
    网络的7层协议
    oracle数据库中,分天查询数目
    求某个字符在字符串中的第5个位置
    高精度乘
    高精度加法
    二叉排序树(建树,先序,中序,后序遍历)
    求哈夫曼树的带权路径长度和
    HDU_1237_简单计算器
  • 原文地址:https://www.cnblogs.com/fuyanan/p/4184401.html
Copyright © 2011-2022 走看看