如何修改示例应用内计费应用程序以启用付费功能?
假设我提供二合一应用程序:免费版和付费版。如果用户付费,那么他将获得应用程序中可用的附加功能。
为了简化任务和理解,我使用了示例应用程序 。然后,我在主屏幕上添加了一个按钮(这是我们的“付费”功能) - 默认情况下禁用此按钮。如果用户为 Potion 付费(在示例应用程序中),则应启用此按钮。
所以,我有以下问题:
- 哪些功能应该修改 在示例应用程序中启用按钮 一旦用户付款?为了简化任务 更多,我们可以假设用户可以购买 只是药剂,仅此而已。看起来 好像还不够添加
myButton.setEnabled(true)
到onPurchaseStateChange / 如果 (购买状态== 仅PurchaseState.PURCHASED)
。 另外,我需要有这个按钮 如果用户在应用程序启动后启用 有薪酬的。我应该这样做吗恢复数据库
?我需要打电话吗 这个restoreDatabase
在onStart()
也可以吗? - 同样的问题是关于按钮的 禁用 - 我应该在哪里执行此操作?
- 一旦按钮启用,如果用户 按下它,我需要验证一下 用户确实为应用程序付费 (不要仅仅依赖数据库值) - 看起来我应该调用
RESTORE_TRANSACTIONS
。然后根据 结果显示警告和 禁用按钮,或允许进一步 行动。
Let's say I provide 2-in-1 app: free and paid version. If user paid, then he gets additional functions available in the application.
To simplify the task and understanding, I took sample application. Then, I've added one more button to the main screen (this is our 'paid' function) - this button is disabled by default. If user paid for Potion (in the sample application), then this button should be enabled.
So, the following questions I have:
- Which functions should be modified
in the sample app to enable button
once user paid? To simplify the task
more, we can assume that user can buy
only Potion, nothing more. Looks
like it is not enough to addmyButton.setEnabled(true)
toonPurchaseStateChange / if
only.
(purchaseState ==
PurchaseState.PURCHASED)
Also, I need to have this button
enabled after application start if user
paid. Should I do it inrestoreDatabase
? Do I need to call
thisrestoreDatabase
inonStart()
also? - The same question is about button
disabling - where should I do this? - Once button is enabled, if user
presses it, I need to verify that
user really paid for the application
(don't rely just on database value) - looks like I should callRESTORE_TRANSACTIONS
. Then based
on result either show warning and
disable button, or allow further
actions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 AndroidBillingLibrary 简化了任务。
Usage of AndroidBillingLibrary simplifies the task.