How do I create a “Licensing add-on” for my Android application?

坚强是说给别人听的谎言 提交于 2019-12-12 08:02:37

问题


I see that some apps on the market come as a Free version, and a "Licensing add-on", where you can use the Free version with its limited features, or buy the license apk which just acts as a license key for the originally "Free" version, to unlock extra features hidden within the "free" version.

Can someone point me to an example of how this can be done?


回答1:


You can use the PackageManager's getInstalledPackages() or getInstalledApplications() to simply check if the license package is installed.

Or, if you want something a bit more sophisticated, you can give the main app and the license apk the same user id in the manifest. This means that both apps can have access to your data (Shared Preferences, SQLite DB, etc). Then the license app just needs to be run once; it can store a value in the shared data indicating that the extended functionality should be enabled. The main app just needs to check this flag and alter its behaviour accordingly.

The advantage of the second approach is that the license app can be uninstalled after being run, and the main app will continue to allow the extended functionality.




回答2:


A better approach might be to look at in-app billing. That would allow you to have multiple 'products' and enable features based on what products people have bought.

The license apk approach is very simple: you know the package of the license apk and check if it is installed. If it is, you assume they have bought it, and enable 'pro' features. The disadvantage is that it is essentially an app that does nothing, and people have to keep it installed. It also gets its own rating and download count, and probably 1-star comments like 'crap, does nothing' from people who don't understand the concept.



来源:https://stackoverflow.com/questions/7137577/how-do-i-create-a-licensing-add-on-for-my-android-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!