如何创建一个"授权附加"我的Andr​​oid应用程序? [英] How do I create a "Licensing add-on" for my Android application?

查看:128
本文介绍了如何创建一个"授权附加"我的Andr​​oid应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到,市场上的一些应用程序会作为一个免费的版本,以及授权附加,在这里你可以使用免费版本的功能有限,或购买许可证 APK 这只是充当了原本免费版本的许可证密钥,解开隐藏在了免费版本的额外功能。

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?

推荐答案

您可以使用 PackageManager getInstalledPackages() getInstalledApplications()来简单地检查是否安装许可证包。

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

或者,如果你想要一些更复杂的,你可以给主要的应用程序和许可证APK相同的在清单的用户ID。这意味着,应用程序可以访问您的数据(共享preferences时,SQLite数据库,等等)。然后许可证的应用程序只需要运行一次;它可以存储在共享数据指示所述扩展功能应启用的值。主要的应用程序只需要检查这个标志并相应地改变它的行为。

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.

这篇关于如何创建一个"授权附加"我的Andr​​oid应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆