android - Using toast in conditional action with thread -
i have created login app login id , password sql server works correct login id, password , gives toast empty login field
but if enter incorrect fields. not showing desired toast. perhaps using toast in wrong place. code is
public void onclick(view v) { // todo auto-generated method stub resultset rs=null; string id=uid.gettext().tostring(); string upass=pass.gettext().tostring(); final string uid1=null; final progressdialog pd=new progressdialog(mainactivity.this); pd.settitle("processing"); pd.setmessage("processing going on..plz patient..."); pd.show(); if(id.equals("")&&upass.equals("")){ toast.maketext(getapplicationcontext(), "empty id or password", toast.length_short).show(); } new thread(){ public void run(){ //defining task progress dialog busy. try{ resultset rs=null; string id=uid.gettext().tostring(); string upass=pass.gettext().tostring(); string uid1=null; if(!id.isempty()&&!upass.isempty()) try{ initilize(); statement statement=connect.createstatement(); rs=statement.executequery("login '"+id+"', '"+upass+"'"); list<string>data=new arraylist<string>(); if(rs.next()){ uid1=rs.getstring("pa_name"); pd.dismiss(); intent i=new intent(getapplicationcontext(),secondactivity.class); i.putextra("a", uid1); startactivity(i); } }catch(exception e){ e.printstacktrace(); } else toast.maketext(mainactivity.this, "invalid id or password", toast.length_long).show();pd.dismiss(); }catch(exception e){ } pd.dismiss(); }}.start();
if 1 suggest me place toast incorrect login id. in conditional statement. it's urgent.
you can create ui objects on main thread. includes toasts. easiest way use activity#runonuithread
show toast. should check out handler
class well.
Comments
Post a Comment