Determine time and date of installation of an app on Android

Asked

Viewed 5,041 times

0

It is possible to obtain the date and time exact that your user has installed the application?

On iOS7+, you can get a receipt from when the app was downloaded using [NSBundle appStoreReceiptURL].

1 answer

1



Getting Installation Time and Date


You can get the time and date of the first time the application was installed through the packageManager:

long installTime = context.getPackageManager()
                   .getPackageInfo("com.some.package.name", 0)
                   .firstInstallTime;

And its respective version:

PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
version = pInfo.versionName;

Unfortunately, this date is reset whenever the application is re-installed.

If you use the following code

PackageManager pm = context.getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo("app.package.name", 0);
String appFile = appInfo.sourceDir;
long installed = new File(appFile).lastModified();

you will be able to determine the application installation date on Android, but the time will always change when it is updated.

  • Machado, I needed to talk to you about Android, how can I contact?... questions with firemonkey

Browser other questions tagged

You are not signed in. Login or sign up in order to post.