如何创建可下载的许可证密钥,并在 Android 上检查它
我确信这是相当基础的,但我不太知道要搜索什么才能获得简洁的教程。我想创建一个应用程序并使其可以在 Android Market 上免费下载。然后,我想创建一个或多个应用程序,这些应用程序只是许可证密钥,可以在免费应用程序上打开某些功能。免费应用程序检查设备上是否存在付费应用程序的最佳方法是什么?有没有一种简单的方法可以通过包名称进行检查,或者我是否需要在付费应用程序中创建一个内容提供程序,免费应用程序可以调用该内容提供程序来检查有效性?
或者可能存在一些所有应用程序都可以读取/写入的全局内存空间(例如应用程序内的首选项)。
我知道一个可行的解决方案,并且我可以轻松实施 - 让每个付费应用程序在首次启动时调用 Web 服务并注册该手机的 IMEI。这可行,但需要互联网访问,这对我的应用程序来说可能方便也可能不方便。
与大多数 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种解决方案基本上是测试您的“许可证”应用程序是否仍然安装在手机上。这样,即使用户更换手机,他仍然可以使用他的谷歌帐户安装许可证应用程序。
您可以使用以下代码获取已安装应用程序的列表:
然后只需找到一个 ApplicationInfo,其中 packageName 成员对应于您的许可证应用程序之一。
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 :
Then just find an ApplicationInfo where the packageName member corresponds to the one of your license app.