How to create a license key as a downloadable, and check for it on Android
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.
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.
精彩评论