Volley Service calling issue in OnResume() android -


hi doing application in have call service inside onresume() method of activity. goes fine,but when application went background time , come volley not responding.below code

private void searchopportunitiesgooglemethod() {          string userregid;         final progressdialog ringprogressdialog = progressdialog.show(quizactivity.this, "please wait ...", "fetching data nearby ...", true);         norecordfound.setvisibility(view.invisible);         ringprogressdialog.setcancelable(false);          final jsonobject child = new jsonobject();         if (session.getuserregisterid() == null) {             userregid = "0";         } else {             userregid = session.getuserregisterid();         }         try {             try {                 child.put("location", signinactivity.nwlocation.getlatitude() + "," + signinactivity.nwlocation.getlongitude());                 child.put("categories", "");                 child.put("types", "");                 child.put("moduleid", moduleid);                 child.put("keywords", "");                 child.put("pageno", 1);                 child.put("pagesize", 10);             } catch (jsonexception e) {                 e.printstacktrace();             }             string radiosstrval;             if (categoryselectionactivity.radiostagval.equals("km")) {                 radiosstrval = session.getradiousname();             } else {                 radiosstrval = session.getradiousname();                 double b = integer.parseint(radiosstrval) * 1.6;                 radiosstrval = string.valueof(b);             }             child.put("radius", radiosstrval);             child.put("userregisterid", userregid);             child.put("state", locationadd.getstate());             child.put("country", locationadd.getcountry1());             child.put("locationflag", "not changed");             //toast.maketext(this, "above child catch",toast.length_short).show();         } catch (jsonexception e) {             e.printstacktrace();             ringprogressdialog.dismiss();            // toast.maketext(this, "below child object",toast.length_short).show();         }                  try {                       jsonobjectrequest jsobjrequest = null;                     try {                         jsobjrequest = new jsonobjectrequest(                                 request.method.post, myurl, child,                                 new response.listener<jsonobject>() {                                      @override                                     public void onresponse(jsonobject response) {                                          try {              //not called when app backgrounded time                                             log.d("tag", "response volley");                                             ongoing = response                                                     .getjsonarray("listongoing");                                             if (ongoing != null) {                                                 if (ongoing.length() != 0) {                                                              livecount.settext("(" + ongoing.length() + ")");                                                   }                                             }                                              upcoming = response                                                     .getjsonarray("listupcoming");                                             expire = response                                                     .getjsonarray("listexpire");                                             if (expire != null) {                                                 if (expire.length() != 0) {                                                              expiredcount.settext("(" + expire.length() + ")");                                                    }                                             }                                                       chkboxexpired.setenabled(true);                                                     // chkboxupcoming.setenabled(true);                                                        if (mproductlistadapter == null) {                                                         mproductlistadapter = new productlistadapter(mcontext,                                                                 mproductlistadapter, lv, quizactivity.arraylist, "userlist");                                                         lv.setadapter(mproductlistadapter);                                                         mproductlistadapter.notifydatasetchanged();                                                       // dialogpro.cancel();                                                     ringprogressdialog.dismiss();                                             mswiperefreshlayout.setrefreshing(false);                                           }                                         catch (jsonexception e)                                         {                                             e.printstacktrace();                                             ringprogressdialog.dismiss();                                         }                                         // dialogpro.cancel();                                         ringprogressdialog.dismiss();                                      }                                   }, new response.errorlistener() {                              @override                             public void onerrorresponse(                                     volleyerror error) {                                 ringprogressdialog.dismiss();                              }                         });                     }                     catch (exception e)                     {                         e.printstacktrace();                         ringprogressdialog.dismiss();                     }                     if (jsobjrequest != null) {                         jsobjrequest.setretrypolicy(new defaultretrypolicy(0, defaultretrypolicy.default_max_retries, defaultretrypolicy.default_backoff_mult));                     }                     appcontroller.getinstance().addtorequestqueue(jsobjrequest);                       } catch (exception e) {                     // dialogpro.cancel();                     log.d("tag", "catch");                     ringprogressdialog.dismiss();                     e.printstacktrace();                 }      } 

this onresume() method

@override     protected void onresume() {         try {             super.onresume();              searchopportunitiesgooglemethod();           } catch (exception e) {             e.printstacktrace();             toast.maketext(this, e.getmessage(), toast.length_long).show();         }         } 


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -