android - run time exception in progress bar -


if (commons.havenetworkconnection()) {                 if ((txt_username.gettext().tostring().trim() != null && txt_username                         .gettext().tostring().length() != 0)// username                                                             // check                         && (txt_password.gettext().tostring().trim() != null && txt_password                                 .gettext().tostring().length() != 0)) {// password                     // check                     pd = progressdialog.show(loginactivity.this.getapplicationcontext(), "","please wait...");                     toast.maketext(getcontext(), "data"+txt_username + txt_password, toast.length_long).show();                     thread thread = new thread(loginactivity.this);                     thread.start();                  } else {                     toast.maketext(getbasecontext(),                             "invalid username or password",                             toast.length_long).show();                 }             } else {                 commons.setonlinealert();             }  }catch(exception e){toast.maketext(getbasecontext(),"problem in onclick 1 block"+e,toast.length_long).show();}         }          private context getcontext() {             // todo auto-generated method stub             return null;         }      }); 

when click on login button runtime exception occur

android.view.windowmanager$badtokenexception: unable add window -- token null not application  

please me how can solve problem

in context method should return context of activity not null

    private context getcontext() {         // todo auto-generated method stub         return loginactivity.this.getapplicationcontext();     } 

and set in toast message below:

      toast.maketext(getcontext(), "data"+txt_username + txt_password, toast.length_long).show(); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -