(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); }
时间: 2024-11-05 17:28:49