progressdialog - Android: Cancel Billing Intent While Waiting for Network -


i trying add progressdialog activity show when billing request loading -- since network request, taking while sometimes. show progress dialog, dismiss when network request finished. however, takes long time , seems hang. if want user able cancel request , dismiss progress dialog, how go adding ability? or, there better way handle network request lag?

here purchasing code:

private void makepurchase(final string s) {     if (makingpayment) return;     makingpayment = true;      mprogressdialog = new progressdialog(donateactivity.this);     mprogressdialog.settitle("google play store");     mprogressdialog.setmessage("loading...");     mprogressdialog.setindeterminate(false);     mprogressdialog.setcancelable(false);     mprogressdialog.setcanceledontouchoutside(false);     mprogressdialog.show();      new thread(new runnable() {         public void run() {             arraylist<string> skulist = new arraylist<string> ();             skulist.add(s);             bundle queryskus = new bundle();             queryskus.putstringarraylist("item_id_list", skulist);             bundle skudetails;             try {                 //network request                 skudetails = mservice.getskudetails(3,                         getpackagename(), "inapp", queryskus);                 mprogressdialog.dismiss();                  int response = skudetails.getint("response_code");                 if (response == 0) {                     arraylist<string> responselist                             = skudetails.getstringarraylist("details_list");                      (string thisresponse : responselist) {                         jsonobject object = new jsonobject(thisresponse);                         string sku = object.getstring("productid");                         if (sku.equals(s)) {                             bundle buyintentbundle = mservice.getbuyintent(3, getpackagename(),                                     sku, "inapp", "bgoa+v7g/yqdxvkrqq+jtfn4uqzbpiqjo4pf9rzj");                             pendingintent pendingintent = buyintentbundle.getparcelable("buy_intent");                             startintentsenderforresult(pendingintent.getintentsender(),                                     1001, new intent(), integer.valueof(0), integer.valueof(0),                                     integer.valueof(0));                         }                     }                 }             } catch (remoteexception e) {                 e.printstacktrace();             } catch (jsonexception e) {                 e.printstacktrace();             } catch (intentsender.sendintentexception e) {                 e.printstacktrace();             } catch (exception e) {                 e.printstacktrace();             }         }     }).start(); } 


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -