Android:应用内:检查是否已购买商品 [英] Android: in-app: check if an item has been purchased

查看:156
本文介绍了Android:应用内:检查是否已购买商品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本教程中介绍了在我的应用程序中实现应用程序:
http://blog.blundell-apps.com/simple-inapp-billing-payment/

I folloed this tutorial to implement in-app in my application: http://blog.blundell-apps.com/simple-inapp-billing-payment/

用户现在可以购买我的物品(com .myitem)与应用内系统。之后,我在共享首选项中设置用户已购买该项目。

The user can now purchase my item (com.myitem) with in-app system. After that, I set in a Shared Preference that the user has been purchased the item.

问题是用户是否卸载并重新安装应用程序。
所以问题是:如何检查用户是否已经购买了该项?

The problem is if the user uninstalla and reinstall the app. So the question is: how can I check if the user has been already purchased the item?

我知道我应该使用restore BillingHelper。 RESTORE_TRANSACTION上的restoreTransactionInformation(...) ...但是在哪里,以及如何?

I know that I should use restore BillingHelper.restoreTransactionInformation(...) on RESTORE_TRANSACTION...but where, and how?

我检查了Dungeon示例,但是看起来很难和复杂的unterstand 。有一个简单的方法吗?

I checked Dungeon example, but it seems to hard and complex to unterstand. There's a simple way to do that?

谢谢

推荐答案

如果您使用托管购买,则使用RESTORE_TRANSACTION是唯一的方法。如果您使用非抽象购买,您可以将购买状态存储在您自己的服务器上,但这并不简单。 RESTORE_TRANSACTIONS没有什么复杂之处:您只需触发命令,就会收到与第一次购买商品时格式完全相同的交易信息。您应该以完全相同的方式处理它,并且您可能已经在应用程序中拥有了该代码。测试这个有点困难,因为它不适用于测试帐户,而且您需要一个实时应用程序。再次阅读官方文档,了解其工作原理。

Using RESTORE_TRANSACTION is the only way if you use managed purchases. If you use unmanagaed purchases, you can store the purchase state on your own server, but that is hardly simpler. There is nothing complex about RESTORE_TRANSACTIONS: you just fire the command and you get notified with transaction information that is in the exact same format as what you get when you first purchase an item. You should process it in the exact same way, and chances are you already have the code for that in your app. Testing this is somewhat harder, because it doesn't really work with test accounts, and you need a live app. Go over the official documentation again to understand how it works.

这篇关于Android:应用内:检查是否已购买商品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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