Android 应用程序内计费 - 如何在应用程序产品中购买时更改布尔值
我想实施应用程序内计费以启用我的应用程序的特定功能。我已经修改了 Android 示例代码,并且运行良好。但是,现在一旦用户购买应用内产品,我就需要对我的应用程序实施更改。我的计划是将布尔值设置为 false,一旦用户购买应用内产品,布尔值将设置为 true,然后将显示之前隐藏的按钮。我的问题是我可以在计费代码中的哪里放置代码来更改我的应用程序的布尔值。从我的所有搜索中,我只找到了“交易成功后”等的“引用”,但这没有帮助。对 Android 示例计费应用程序中的代码的任何具体引用都会很有用。
I want to implement In app billing to enable a particular feature with my app. I've modified the Android sample code and it is working fine. However, now I need to implement the change to my app once the user buys the in app product. My plan is to have a boolean value set to false and once the users buys the in app product, the boolean value will be set to true and then a previously hidden button will be revealed. My questions is where in the billing code can I place the code to change the boolean value of my app. From all my searches I've only found 'references' to 'once the transaction is successful', etc, but that is not helpful. Any specific references to code from the android sample billing application would be useful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要保留该信息,因此仅设置布尔标志是不够的。 Dungeons 应用使用数据库,因此请参阅该部分代码作为示例:
PurchaseDatabase
类及其insertOrder()
、updatePurchasedItem()方法。对于您的情况(单一产品/功能),设置布尔首选项可能就可以了。
You need to persist that information, so just setting a boolean flag won't do it. The Dungeons app uses a database, so refer to that part of the code for a sample: the
PurchaseDatabase
class and itsinsertOrder()
,updatePurchasedItem()
methods. For you your case (single product/feature), setting a boolean preference will probably do.