一、获取网络状态
/**
* 获取手机所有连接管理对象
*/
public static boolean checkNet(Context context) {// 获取手机所有连接管理对象(包括对wi-fi,
// 如果没有网络连接,则进入网络设置界面
//context.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
// net等连接的管理
ConnectivityManager connectivity = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
// 获取网络连接管理的对象
NetworkInfo info = connectivity.getActiveNetworkInfo();
if (info == null || !info.isAvailable()) {
return false;
} else {
return true;
}
}
return false;
}
二、判断是否是中文
中文:getResources().getConfiguration().locale.getCountry().equals("CN")
繁体中文: getResources().getConfiguration().locale.getCountry().equals("TW")
英文(英式):getResources().getConfiguration().locale.getCountry().equals("UK")
英文(美式):getResources().getConfiguration().locale.getCountry().equals("US")