我有我讓他們與此代碼如何在我的情況比較字符串(機器人)
final String encrypted_id = encryption.encryptOrNull(android_id);
final String preLoad = preferences.getString("pur", "no");
爲確保他們是平等的我登錄他們這樣
Log.d("encrypted_id",encrypted_id);
Log.d("preferences.getString",preferences.getString("pur", "no"));
兩個String和logcat的輸出是這樣
D/encrypted_id﹕ wxgNDxqzNWNgYWrE0fxjaU07a54XBFnAToy56MAV1Y0=
D/preferences.getString﹕ wxgNDxqzNWNgYWrE0fxjaU07a54XBFnAToy56MAV1Y0=
所以我要確保他們是平等的
NOW我想他們這樣
if(preLoad.equals(encrypted_id))
{
Log.d("app","is premium");
}
else {
Log.d("app","is not premium");
}
但 logcat的節目比較這對我
D/app﹕ is not premium
什麼問題?
PS:我試過
1 . preLoad.equalsIgnoreCase(encrypted_id)
2 . preLoad.compareTo(encrypted_id)==0
你試過preLoad.trim()。equals(encrypted_id.trim())??? –
你可以在else中打印'encrypted_id'和'preLoad'嗎? – ThomasThiebaud
使用equalignore情況下,也修剪(),然後檢查 – Pavya