Determine date (or version) that app was purchased from Google Play Store - equivalent of iOS appStoreReceiptURL Determine date (or version) that app was purchased from Google Play Store - equivalent of iOS appStoreReceiptURL ios ios

Determine date (or version) that app was purchased from Google Play Store - equivalent of iOS appStoreReceiptURL



Getting Time and Date Install


You can get the time and date of the first install of the app by using

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

And the version with

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

Unfortunately this date will reset whenever the app is uninstalled and reinstalled.

If you go with

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

you will also find out the date when an application was installed, but the time returned will change every time the package is updated.


Suggested Solution


A solution could be an online database for your application, where you can store each user's ID using AccountPicker, their first-time-install with the methods described above and use them at login. You can also use the App Licensing Service.

http://developer.android.com/reference/android/content/pm/PackageInfo.html#firstInstallTime