有人在 Nexus 6P 设备上遇到这个问题吗?我只在运行 Google Fi 的 Nexus 6P 上遇到了这个问题。
当我安装应用程序时,在 SharedPreferences
中有一个名为userIsLoggedIn
的密钥。
这个代码块:
boolean userIsLoggedIn = SharedPrefs.userIsLoggedIn(this);
// Then in another class...
public static boolean userIsLoggedIn(Context context) {
// For users updating apps, if the previous key-value is a string, convert it to boolean
try {
return context.getSharedPreferences(LOGIN_FILE, Context.MODE_PRIVATE)
.getBoolean(USER_LOGGED_IN, false);
} catch (ClassCastException e) {
Logger.e(TAG, e.getMessage());
context.getSharedPreferences(LOGIN, Context.MODE_PRIVATE)
.edit()
.putBoolean(USER_LOGGED_IN, false)
.commit();
return context.getSharedPreferences(LOGIN, Context.MODE_PRIVATE)
.getBoolean(USER_LOGGED_IN, false);
}
}
现在在新的卸载操作中,这应该返回 false
,但我在全新安装上进行调试时,在应用启动时得到以下结果。
我也在运行 Proguard,如果有影响的话,当在没有启用 Proguard 的 APK 上运行设备时,它可以正常运行。在其他设备上运行 Proguard 也是正常的。