문자열 비교에 문제가 있습니다. string.xml에 "activation"이라는 문자열 값이 있습니다. 나도 같은 값을 갖는 문자열 값과 비교하면, 결과는 항상 false입니다 (string.xml 활성화에 = 테스트)getString() string.xml compare
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MyNameApp</string>
<string name="activation">test</string>
</resources>
public class CheckGenuine {
public static String cod;
public static String app;
public static Boolean chk(Context ctx) {
Boolean ret;
cod = ctx.getString(R.string.activation);
app = ctx.getString(R.string.app_name);
if (cod == "test") {
Toast.makeText(ctx, "True cod = " + cod, Toast.LENGTH_LONG).show();
ret = true;}
else {
Toast.makeText(ctx, "False cod = " + cod, Toast.LENGTH_LONG).show();
ret = false;}
// *** why ret is always false and Toast shows "False cod = test" ????????????????
return ret;
}
}
고마워요! 나는 미쳐 가고 있었다 :-) – user1549319