In-app billing workflow in a ListView

前端 未结 2 848
我在风中等你
我在风中等你 2021-01-06 09:52

I implemented in-app billing in Android application, have like 6 product they are like coins the user will buy in order to buy items in my app. The setup and the testing for

相关标签:
2条回答
  • 2021-01-06 10:21

    Since you're consuming multiple items, would suggest to use consumeAsync for multiple items method by passing your list of purchases. You can find it inside TrivialDrive sample app for Iab ver 3

    /**
     * Same as {@link consumeAsync}, but for multiple items at once.
     * @param purchases The list of PurchaseInfo objects representing the purchases to consume.
     * @param listener The listener to notify when the consumption operation finishes.
     */
    public void consumeAsync(List<Purchase> purchases, OnConsumeMultiFinishedListener listener) {
    

    Use onConsumeMultiFinished as your callback

    public void onConsumeMultiFinished(List<Purchase> purchases, List<IabResult> results);
    

    It should take care of sending proper async consume requests. Update you code and post any problems.

    0 讨论(0)
  • 2021-01-06 10:30

    change your class to these

    public class BankClass {
    
        public int itemId;
        public int quantity;
        public String Price;
    
        public BankClass(int _itemId,int _quantity,String _Price){
            itemId = _itemId;
            quantity = _quantity;
            Price = _Price;
        }
    
        public int getItemId() {
            return itemId;
        }
    
        public String getPrice() {
            return Price;
        }
    
        public int getQuantity() {
            return quantity;
        }
    }
    

    in listitem click change these all code like bewlo

    BankClass currentItem = BankList.get(position);
                        CoinItemID = currentItem.getItemId();
                        if (currentItem.getQuantity() == 100)
                        {
                            CoinItemID = currentItem.getItemId();
                            String payload = "";
                            mHelper.launchPurchaseFlow(BankActivity.this, SKU_hundred, RC_REQUEST,
                                    mPurchaseFinishedListener, payload);
    
                        }
    
    0 讨论(0)
提交回复
热议问题