Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'd like to determine which version of my Android app a user originally purchased from the Google Play Store. I need this info to help support moving from a paid app model to a freemium model.

In iOS7 onwards, you can do this by using [NSBundle appStoreReceiptURL] which returns a URL of the App Store receipt that can be examined.

Is there an equivalent in the Google APIs?

like image 535
Carlos P Avatar asked Nov 04 '13 09:11

Carlos P


People also ask

How do I find out when I downloaded an app from Google?

You can view the app download history in Google Play Store from the Installed or Library sections of the Store. The Installed section shows you all the apps currently installed on your Android device.

How do I find the developer version of an app in Google Play?

On Android mobile devicesBrowse or search for the app. Tap the app to open the detail page. Tap Developer contact.

How can I tell when an app was created?

Android keeps a log of when an app (it's component) was last used. You can head down to /data/system/usagestats/ using a file explorer with root access, or using adb. There would be a file named usage-history.


1 Answers


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


like image 65
Machado Avatar answered Sep 19 '22 19:09

Machado