简体   繁体   English

如何记住在Android应用程序计费服务中是否购买了该商品?

[英]How to remember that the item is purchased or not in android app billing service?

In my app I have done the below code in the dungeons sample project to check whether the item is purchased or not and changing my text of a list item : 在我的应用程序中,我在dungeons示例项目中完成了以下代码,以检查是否购买了该商品并更改了列表商品的文本:

@Override
        public void onPurchaseStateChange(PurchaseState purchaseState,
                String itemId, int quantity, long purchaseTime,
                String developerPayload) {
            if (Consts.DEBUG) {
                Log.i("Tag", "onPurchaseStateChange() itemId: " + itemId + " "
                        + purchaseState);
            }

            if (purchaseState == PurchaseState.PURCHASED) {
                ownedItems.add(itemId);
                list.get(purchaseposition).setPurchase("Play");
                adapter.notifyDataSetChanged();
            }
            // YOU can also add other checks here
        }

but when I re run the application it can not remember that I have already bought the item and it prompt me to buy it again. 但是当我重新运行该应用程序时,它不记得我已经购买了该物品,并提示我再次购买。 How can i do this? 我怎样才能做到这一点? Its looking a little bit of complicated for me. 对我来说,看起来有点复杂。

There are two types of in app purchase, one is managed and other is un-managed for managed items the play.google will take care of the item even after reinstallation of application on device while for un-managed you have to take care of the purchases by yourself. 应用内购买有两种类型,一种是托管的,另一种是非托管的,对于托管商品,即使在设备上重新安装应用程序后,play.google也会照顾该商品;对于非托管,您必须照顾自行购买。 as you can see details in below link http://developer.android.com/guide/market/billing/billing_admin.html#billing-purchase-type 如您在以下链接中看到的详细信息http://developer.android.com/guide/market/billing/billing_admin.html#billing-purchase-type

also answer to this question explaining the difference between managed and un managed products 还回答这个问题,解释托管产品和非托管产品之间的区别

Difference between managed and unmanaged in-app product android? 托管和非托管应用内商品android之间的区别?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM