Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I used the google sample Trivialdrive and I published the beta test. And I can buy my item, no problem. But I am trying to getPrice() a item and always "No found". Can you help me please. Thanks.

------- in IabHelper.class ------

Java
public String getPricesDev(String packageName) throws RemoteException, JSONException{

    final String PACKAGE_NAME = mContext.getPackageName();

    ArrayList<String> skuList = new ArrayList<String>();
    skuList.add("infinite_gas_monthly");
    skuList.add("gas");
    skuList.add("infinite_gas");
    skuList.add("premium");
    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList("ITEM_ID_LIST", skuList);

    Bundle skuDetails = mService.getSkuDetails(3,PACKAGE_NAME, "inapp", querySkus);

    int response = skuDetails.getInt("RESPONSE_CODE");
    if (response > 0) {
        ArrayList<String> responseList
                = skuDetails.getStringArrayList("DETAILS_LIST");

        for (String thisResponse : responseList) {
            JSONObject object = new JSONObject(thisResponse);
            String sku = object.getString("productId");
            String price = object.getString("price");
          if(sku.equals("infinite_gas_monthly")) return price;
        }
    }
    return "Not found";
}


Java
------ in Mainactivity.class ----

IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
    public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
        // Have we been disposed of in the meantime? If so, quit.
        if (mHelper == null) return;
        // Is it a failure?
        if (result.isFailure()) {
            complain("Failed to query inventory: " + result);
            return;
        }

        try{
            tx1.setText(mHelper.getPricesDev("infinite_gas_monthly"));
        }catch (RemoteException r){
        }catch (JSONException j){
        }
          ......
     };


What I have tried:

I tried IabHelper.class. Google sample inapp application Trivialarive.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900