2013-01-02 339 views
1

誰能請告訴我如何獲取可用的產品清單的報價?我使用reference.suppose在我的應用程序開發者控制檯上微不足道的驅動例子,我列出了兩個產品作爲產品1 &產品2.How獲得可用產品列表在我的app.Please幫助。在應用程序購買?

回答

0

試試這個,

IabHelper billingHelper = new IabHelper(this, AppPublicKey.BASE_64_KEY); 

       billingHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { 

        @Override 
        public void onIabSetupFinished(IabResult result) { 
         if (!result.isSuccess()) { 
          // Oh noes, there was a problem. 
          complain("Problem setting up in-app billing: " + result); 
          return; 
         } 

         // Have we been disposed of in the meantime? If so, quit. 
         if (billingHelper == null) return; 
         List<String> aListSKU = new ArrayList<String>(); 
         aListSKU.add(ProductId.SKU100); 
         aListSKU.add(ProductId.SKU200); 
         aListSKU.add(ProductId.SKU400); 
         billingHelper.queryInventoryAsync(true, aListSKU, mGotInventoryListener); 
        } 
       }); 

創建QueryInventoryFinishedListener接口

  // Listener that's called when we finish querying the items and subscriptions we own 


    IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() { 

       @Override 
       public void onQueryInventoryFinished(IabResult result, Inventory inventory) { 

        // Have we been disposed of in the meantime? If so, quit. 
        if (billingHelper == null) return; 

        // Is it a failure? 
        if (result.isFailure()) { 
         Toast.makeText(ProfileCreditActivity.this, "Failed to query inventory: " + result, Toast.LENGTH_SHORT).show(); 
         return; 
        } 

        Log.d(TAG, "Query inventory was successful."); 

        SkuDetails sku100Details = inventory.getSkuDetails(ProductId.SKU100); 
        sku100Price = sku100Details.getPrice(); 
        sku100Title = sku100Details.getTitle(); 

        SkuDetails sku200Details = inventory.getSkuDetails(ProductId.SKU200); 
        sku200Price = sku200Details.getPrice(); 
        sku200Title = sku100Details.getTitle(); 

        SkuDetails sku400Details = inventory.getSkuDetails(ProductId.SKU400); 
        sku400Price = sku400Details.getPrice(); 
        sku400Title = sku100Details.getTitle(); 



        updateUI(); 
       } 

      }; 

更新你的UI在這裏

private void updateUI() { 

    }