首页 > 其他 > 详细

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

时间:2014-12-25 14:14:37      阅读:280      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!