2013-01-11 7 views
6

Ho un programma che imposta una finestra di avviso che chiede "Vorresti acquistare" TITOLO "per" PREZZO ""Nell'IAB di Google, posso ottenere il titolo e il prezzo del prodotto prima di chiamare il metodo launchpurchaseflow?

So che la libreria Google IAB ha una chiamata getSku() ma che è disponibile solo dopo un risultato dall'acquisto dell'oggetto. C'è un modo per ottenere queste due variabili prima di qualsiasi acquisto? Grazie.

avrei potuto vedere una voce che interroga un fascio di SKU che elenca tutte le voci, ma posso sbagliarmi

risposta

1

trovato una soluzione per questo. prima di tutto avrai bisogno dello sku/id prodotto.

public void getProductDetails(String sku) throws RemoteException, JSONException { 
    logDebug("getProductDetails - " + sku); 

    ArrayList<String> skuList = new ArrayList<>(); 
    // Add the specific sku 
    skuList.add(sku); 

    if (sku != null) { 
     Bundle querySkus = new Bundle(); 
     querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList); 
     Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), ITEM_TYPE_INAPP, querySkus); 
     ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST); 

     for (String thisResponse : responseList) { 
      SkuDetails d = new SkuDetails(thisResponse); 
      logDebug("Looking at sku details: " + d); 
      purchaseTitle = d.getTitle(); // these are set as variables so you can call them 
      purchasePrice = d.getPrice(); // whenever you want 
     } 
    } 
} 
+0

sto utilizzando in -app fatturazione della versione 3 e necessità di recuperare i dettagli del prodotto dell'abbonamento, per i quali ho fatto in funzione "mGotInventoryListener" if (inventory.getSkuDetails (SKU_INFINITE_SUBSCRIPTION)! = null) { \t \t \t \t Log.e (TAG, "prezzo dettagli prodotto ====" + inventory.getSkuDetails (SKU_INFINITE_SUBSCRIPTION) .getPrice()); \t \t \t \t \t \t \t} Ma sto ottenendo i dati come nullo – AkashG

+0

può u pls darmi una mano per ottenere i dettagli della sottoscrizione .. – AkashG

2

utilizzare questo metodo in IABHelper:

List<String> moreSkus = new ArrayList<String>(); 
    moreSkus.add("sku1"); 
    moreSkus.add("sku2");    

    mHelper.queryInventoryAsync(true, moreSkus, mGotInventoryListener); 

I test funziona bene, è possibile aggiungere inapp o sottotipo sku alla lista, e restituire tutti i dettagli in invenroty

+0

Will funziona con IAB V2. Sto ottenendo l'errore come "queryInventoryAsync" non trovato. Se non è possibile, fatemi sapere se esiste un altro modo per ottenere i dettagli del prodotto con V2 – Ganesh

Problemi correlati