import java.util.Locale;
private void setDataEnabled(Context context,boolean enable) {
if(telephonyService == null){
telephonyService = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
}
telephonyService.setDataEnabled(enable);
String locale = Locale.getDefault().getLanguage(); //获取本地(系统)默认语言
if(enable){
if (locale.endsWith("zh")) {
setToast(context,"移动网络已打开!");
}else{
setToast(context,"Mobile network open!");
}
}else{
if (locale.endsWith("zh")) {
setToast(context,"移动网络已关闭!");
}else{
setToast(context,"Mobile network close!");
}
}
android根据系统语言,改变语言
最新推荐文章于 2025-04-09 16:39:25 发布