码迷,mamicode.com
首页 > 其他好文 > 详细

(三十二)工具方法:如何判断是否有网络/如何调用系统设置界面

时间:2014-12-25 14:17:20      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

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

    /**
     * 判断是否有网络
     * @return
     */
    private boolean isNetWorkConnected() {
        // TODO Auto-generated method stub
        ConnectivityManager cm = (ConnectivityManager) 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 setNetWork() {
        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);
    }

 

(三十二)工具方法:如何判断是否有网络/如何调用系统设置界面

标签:

原文地址:http://www.cnblogs.com/fuyanan/p/4184401.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!