android - Will this code consume all purchases of managed Items V3 for this user? -


i found code on web. think can release managed items , make them available purchase again or need modification? seems i'm not able test correctly. looks need test button release managed items. on right track or totally misguided ? need opinion please don't have release managed items ...

 public  void consumeallolderitems() {     bundle owneditems = null;     try {         owneditems = mhelper.mservice.getpurchases(3, sgame.getcontext().getpackagename(), "inapp", null);     } catch (remoteexception e1) {         // todo auto-generated catch block         e1.printstacktrace();     }     int response = owneditems.getint("response_code");      if (response == 0)     {         alertnonstatic("consumeallolderitems() google responded ok our consumables");         arraylist<string> ownedskus = owneditems.getstringarraylist("inapp_purchase_item_list");         arraylist<string> purchasedatalist = owneditems.getstringarraylist("inapp_purchase_data_list");         arraylist<string> signaturelist = owneditems.getstringarraylist("inapp_data_signature");         //string continuationtoken = owneditems.getstring("inapp_continuation_token");         if(purchasedatalist != null && purchasedatalist.size() > 0)         (int = 0; < purchasedatalist.size(); ++i) {             try {                 string purchasedata = purchasedatalist.get(i);                 jsonobject jo = new jsonobject(purchasedata);                 if(jo != null && jo.length() > 0);                 final string token = jo.getstring("purchasetoken");                 string sku = null;                 string sig = null;                 if (ownedskus != null){                     sku = ownedskus.get(i);                     if (signaturelist != null && signaturelist.size() > 0){                          sig = signaturelist.get(i);                     }                      consume(sku, token, purchasedata,sig);                  }              } catch (jsonexception e) {                 e.printstacktrace();             }          }     }     else if(response != 0){         alertnonstatic("response older items "+response);     }  }        private  void consume(string sku, string token, string purchasedata,string sig) {     alertnonstatic("consume trying consume item");     purchase purchace = null;     try {         purchace = new purchase("inapp", purchasedata, sig);     } catch (jsonexception e) {          e.printstacktrace();     }      mhelper.consumeasync(purchace,mconsumefinishedlistener);  } 

there no reason re-create purchase object use consumeasync since recomendation on google docs says spawn new thread , on :

int response = mservice.consumepurchase(3, getpackagename(), token);


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -