You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. isFirstTimeInstall():
If you want to know whether this is the first time installation of this app in this device.
2. isAppUpgraded():
If you want to know whether the current version was installed over a previous version (update/upgrade) or if it is freshly installed (clean install).
Code:
/**
* Return true if this is the first ever time that the application is installed on the device.
*
* @return true if this is the first ever time that the application is installed on the device.
*/
public static boolean isFirstTimeInstall(){
try {
Long firstInstallTime = Utils.getApp().getPackageManager().getPackageInfo(this.getAppPackageName(), 0).firstInstallTime;
Long lastUpdateTime = Utils.getApp().getPackageManager().getPackageInfo(this.getAppPackageName(), 0).lastUpdateTime;
return firstInstallTime == lastUpdateTime;
} catch (Exception e) {
return false;
}
}
/**
* Return true if app was previously installed and this one is an update/upgrade to that one, returns false if this is a fresh installation and not an update/upgrade.
*
* @return true if app was previously installed and this one is an update/upgrade to that one, returns false if this is a fresh installation and not an update/upgrade.
*/
public static boolean isAppUpgraded(){
try {
Long firstInstallTime = Utils.getApp().getPackageManager().getPackageInfo(this.getAppPackageName(), 0).firstInstallTime;
Long lastUpdateTime = Utils.getApp().getPackageManager().getPackageInfo(this.getAppPackageName(), 0).lastUpdateTime;
return firstInstallTime != lastUpdateTime;
} catch (Exception e) {
return false;
}
}
* Return true if app was previously installed and this one is an update/upgrade to that one, returns false if this is a fresh installation and not an update/upgrade.
405
+
*
406
+
* @return true if app was previously installed and this one is an update/upgrade to that one, returns false if this is a fresh installation and not an update/upgrade.
0 commit comments