无需互联网连接的许可系统
我正在测试 Android 的许可系统。确切地说,我刚刚使用 ServerManagedPolicy 编译了示例项目,我有一个问题: 如果我这样做:
Device's Internet=ON
Launch the app
Launch the check= Allow access
Device's Internet=OFF
Relaunch app and check= Allow access
好的,现在让我们看看问题:
Device's Internet=OFF
Launch the app
Launch the check= Don't allow access
从逻辑上讲,我不希望这样。因为如果用户在没有互联网的情况下启动该应用程序,即使该应用程序已获得许可,该应用程序也会被阻止。我该如何解决这个问题?我的应用程序需要连接到互联网才能工作,因此延迟检查没有问题
I'm testing the licensing system for android. Exactly I just compiled the sample project with ServerManagedPolicy and I have a question about it:
If I do:
Device's Internet=ON
Launch the app
Launch the check= Allow access
Device's Internet=OFF
Relaunch app and check= Allow access
Ok now lets see the problem:
Device's Internet=OFF
Launch the app
Launch the check= Don't allow access
Logically I don't want that. Because the app will be blocked if the user launches the app without Internet, even if it was licensed. How can I solve that? My application needs to be connected to the Internet for working so there's no problem in delaying that check
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用带有handleResponse()的自定义LicenseValidator类,仅当策略返回LicenseResponse.NOT_LICENSED时,该类才会在许可证检查器回调上调用dontAllow(),并在所有其他情况下(包括网络错误)调用allow()。
并使用自定义策略而不是 ServerManagedPolicy:
}
这只是我所做的,而且效果很好。
You may use a custom LicenseValidator class with a handleResponse() that would call dontAllow() on the License checker callback only when the policy returns LicenseResponse.NOT_LICENSED, and allow() in all other cases including network error.
And use also a custom Policy instead of the ServerManagedPolicy:
}
This is petty much what I did and it works fine.