I have an app with a Login functionality and also auto Login, and before login screen, a Splash Screen Activity is displayed. Inside Splash Screen activity I want to check if the user has just updated the app from the Google play to a newer version, and if so, to always show him the Login screen. So my question is, how to check if current version app is different from the last version? I tried solutions found in this topic: Detect if new install or updated version (Android app)
But in this function
public static boolean isInstallFromUpdate(Context context) {
try {
long firstInstallTime = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).firstInstallTime;
long lastUpdateTime = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).lastUpdateTime;
return firstInstallTime != lastUpdateTime;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return false;
}
}
This line is always true: firstInstallTime != lastUpdateTime;, but after an update, if I close the app and then reopen it, this line should be false. If you have any suggestions or need more details, please let me know! Thanks