java - Onpostexecute method is never used -


i'm getting "onpostexecute method never used" error , hence dialog box never closes, not sure mistake is. i'm sure mistake brackets somewhere i've been trying figure out while , can't, perhaps fresh pair of eyes can in case.

    public void oncreate(bundle savedinstancestate) {              super.oncreate(savedinstancestate);                setcontentview(r.layout.activity_display_all_bets);                  name = (getintent().getextras().getstring("user")).tolowercase();              log.d("name", name);              // hashmap listview              bet = new arraylist<hashmap<string, string>>();                // loading products in background thread              new loadallgames().execute();            }              /**               * background async task load product making http request               */              class loadallgames extends asynctask<string, string, string> {                  private string id;                  private string stake;                  private string user;                  private string returns;                  private string teams;                  private string status;                      //  *//**                  //   * before starting background thread show progress dialog                  //    *//*                  @override                  protected void onpreexecute() {                      super.onpreexecute();                      pdialog = new progressdialog(displayallbets.this);                      pdialog.setmessage("loading games. please wait...");                      pdialog.setindeterminate(false);                      pdialog.setcancelable(false);                      pdialog.show();                  }                    //  *//**                  //    * getting products url                  //    *//*                  protected string doinbackground(string... args) {                      // building parameters                      httpclient client = new defaulthttpclient();                      httppost post = new httppost(url_all_games);                      list<namevaluepair> params = new arraylist<namevaluepair>();                      params.add(new basicnamevaluepair("email", name));                      try {                          post.setentity(new urlencodedformentity(params));                      } catch (ioexception ioe) {                          ioe.printstacktrace();                      }                      try {                          httpresponse response = client.execute(post);                          log.d("http post response:", response.tostring());                          httpentity httpentity = response.getentity();                          inputstream = httpentity.getcontent();                          jsonobject jobj = null;                          string json = "";                          try {                              bufferedreader reader = new bufferedreader(new inputstreamreader(                                      is, "iso-8859-1"), 8);                              stringbuilder sb = new stringbuilder();                              string line = null;                              while ((line = reader.readline()) != null) {                                    if (!line.startswith("<", 0)) {                                      if (!line.startswith("(", 0)) {                                          sb.append(line + "\n");                                      }                                  }                              }                                is.close();                              json = sb.tostring();                              json = json.substring(json.indexof('{'));                              log.d("sb", json);                            } catch (exception e) {                              log.e("buffer error", "error converting result " + e.tostring());                          }                            // try parse string json object                          try {                              jobj = new jsonobject(json);                          } catch (jsonexception e) {                              log.e("json parser", "error parsing data " + e.tostring());                          }                            // return json string                          log.d("json", jobj.tostring());                          try {                              allgames = jobj.getjsonarray(tag_bet);                              log.d("allgames", allgames.tostring());                              // looping through products                              (int = 0; < allgames.length(); i++) {                                  jsonobject c = allgames.getjsonobject(i);                                    // storing each json item in variable                                  string id = c.getstring(tag_id);                                  string user = c.getstring(tag_user);                                  string returns = c.getstring(tag_returns);                                  string stake = c.getstring(tag_stake);                                  string status = c.getstring(tag_status);                                  string teams = c.getstring(tag_teams);                                  log.d("id", id);                                  log.d("user", user);                                  log.d("returns", returns);                                  log.d("stake", stake);                                  log.d("status", status);                                  log.d("teams", teams);                                      // creating new hashmap                                  hashmap<string, string> map = new hashmap<string, string>();                                    // adding each child node hashmap key => value                                  map.put(tag_id, id);                                  map.put(tag_teams, teams);                                  map.put(tag_user, user);                                  map.put(tag_returns, returns);                                  map.put(tag_stake, stake);                                  map.put(tag_status, status);                                      // adding hashlist arraylist                                  bet.add(map);                              }                              } catch (jsonexception e) {                              e.printstacktrace();                          }                      } catch (ioexception ioe) {                          ioe.printstacktrace();                      }                          return "";                  }                                      @override                  protected void onpostexecute() {                      // dismiss dialog after getting products                      // updating ui background thread                      pdialog.dismiss();                      }                }                  @override              public boolean oncreateoptionsmenu(menu menu) {                  // inflate menu; adds items action bar if present.                  getmenuinflater().inflate(r.menu.menu_display_all_bets, menu);                  return true;              }                @override              public boolean onoptionsitemselected(menuitem item) {                  // handle action bar item clicks here. action bar                  // automatically handle clicks on home/up button, long                  // specify parent activity in androidmanifest.xml.                  int id = item.getitemid();                    //noinspection simplifiableifstatement                  if (id == r.id.action_settings) {                      return true;                  }                    return super.onoptionsitemselected(item);              }          }

you defined asynctask as,

class loadallgames extends asynctask<string, string, string> 

for which, should have onpostexecute(string) type

@override     protected void onpostexecute(string param) {     // dismiss dialog after getting products     // updating ui background thread     pdialog.dismiss(); }                

should work.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -