我正在尝试一个简单的检查。如果字符串名称语言环境具有“es”作为值。正在执行不寻常的android逻辑运算符不能比较两个字符串
public String locale =
Locale.getDefault().getLanguage().toLowerCase().toString();
// ...
Log.v(tag, "Idioma del sistema: «" + locale +"»");
if (locale != "es") {
showDialog(R.string.warningTitleDialog,
"We are sorry that this tool is only available in Spanish " +
"language. See Author menu item for more information. [" +
locale + "]");
locale = "en";
}
adb logcat
显示为“es”串“区域”,但条件内码的内容。
==和!=运算符比较地址 – nandeesh
是的,这就是为什么他总是错误的原因。 –