5

I'm sure this is fairly basic, but I don't know quite what to search on to get a concise tutorial. I want to create an app and make it downloadable on the Android Market for free. Then, I want to create one or more apps which are just license keys which open up certain functionality on the free app. What's the best way for the free app to check if the paid apps are present on the device? Is there an easy way to check by package name or do I need to create a content provider in the paid apps which the free app can call to check validity?

Or maybe there's some global memory space (like preferences within an app) which all apps can read/write.

I know one solution that would work, and that I could implement easily - have each paid app call a web service when it first starts and register that phone's IMEI. This would work, but requires internet access, which may or may not be convenient for my app.

As with most Android problems - more than one way to skin a cat. I'm looking for what you guys think is the best (and most secure) approach.

sorin
  • 161,544
  • 178
  • 535
  • 806
RMS2
  • 707
  • 3
  • 8
  • 19
  • Surely the user would have to download the license key apps, meaning the web service would be ideal as it prevents other apps cropping up that unlock the services for free (as it could if you used a global memory type solution). – Blam Sep 10 '10 at 15:20
  • Have a look at this question: http://stackoverflow.com/questions/3384457/how-to-check-android-licensing-permission-of-other-applications – Janusz Sep 10 '10 at 15:22
  • Thanks for pointing me to that other question. That is my same problem. One problem with the web service idea is that the license app calls the webservice and registers the phone's IMEI, and that works great in the normal case, but what happens if the user uninstalls and refunds the license app? I have no way of knowing that and removing the registration. No, I think the free app needs to make sure those licenses are installed at the time of execution. – RMS2 Sep 10 '10 at 15:55

1 Answers1

1

One solution would basically to test if your "license" app is still installed on the phone. Then even if the user change phone, he'll still be able to install the license app using his google account.

You can get the list of installed applications using the following code :

List<ApplicationInfo> list = context.getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA);

Then just find an ApplicationInfo where the packageName member corresponds to the one of your license app.

XGouchet
  • 10,002
  • 10
  • 48
  • 83