clicking report activity nothing was happening in android -


hi in below code when clicking report button not going login activity though it's not happening anything. in login activity first of checking login username , password using session object. if username , password working fine , want move next activity.

can 1 me issue.

mainactivity.java

report1=(textview)findviewbyid(r.id.report1);         report=(imageview)findviewbyid(r.id.report);         report1.setonclicklistener(new onclicklistener() {              @override             public void onclick(view v) {                  intent i=new intent(getapplicationcontext(),login.class);                 startactivity(i);             }         });         report.setonclicklistener(new onclicklistener() {              @override             public void onclick(view v) {                  intent i=new intent(getapplicationcontext(),login.class);                 startactivity(i);             }         }); 

in below when putting comment session it's moving after entering username , password showing logcat admin user found not going next activity.it staying in same activity itself.

update login

public class login extends activity { imagebutton login; private static final pattern username_pattern = pattern         .compile("[a-za-z0-9]{1,250}"); private static final pattern password_pattern = pattern         .compile("[a-za-z0-9+_.]{4,16}"); edittext usname,pword,ustype; textview tv,tv1; boolean isinternetpresent = false; string username,password; httppost httppost; stringbuffer buffer; string querystring; string data=""; int i; httpresponse response; httpclient httpclient; checkbox mcbshowpwd; sessionmanager session;  private progressdialog progressdialog;    connectiondetector cd;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     this.requestwindowfeature(window.feature_no_title);     setcontentview(r.layout.login);    // session = new sessionmanager(getapplicationcontext());    // session.checklogin();      // final hashmap<string, string> user = session.getuserdetails();        login = (imagebutton)findviewbyid(r.id.login);        usname = (edittext)findviewbyid(r.id.username);     pword= (edittext)findviewbyid(r.id.password);     ustype= (edittext)findviewbyid(r.id.usertype);     tv = (textview)findviewbyid(r.id.tv);     tv1 = (textview)findviewbyid(r.id.tv1);     mcbshowpwd = (checkbox) findviewbyid(r.id.cbshowpwd);     cd = new connectiondetector(getapplicationcontext());    mcbshowpwd.setoncheckedchangelistener(new oncheckedchangelistener() {          public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) {              if (!ischecked) {                  pword.settransformationmethod(passwordtransformationmethod.getinstance());             } else {                   pword.settransformationmethod(hidereturnstransformationmethod.getinstance());             }         }     });      login.setonclicklistener(new onclicklistener() {        @override        public void onclick(view v) {             new loadviewtask().execute();                isinternetpresent = cd.isconnectingtointernet();            if (!isinternetpresent) {                showalertdialog(login.this, "no internet connection",                        "you don't have internet connection.", true);                 return;              }             string username = usname.gettext().tostring();            string password = pword.gettext().tostring();            // string name = user.get(sessionmanager.key_username);                  if (username.equals("")) {                    toast.maketext(login.this, "enter username",                            toast.length_long).show();                 }                if (password.equals("")) {                    toast.maketext(login.this, "enter password",                            toast.length_long).show();                 }            else if (!checkusername(username) && !checkpassword(password)){                    toast.maketext(login.this, "enter valid username & password",                          toast.length_long).show();            }            else{                querystring = "username=" + username + "&password="                         + password ;               string usertype = databaseutility.executequeryphp("login",querystring);               system.out.print(usertype);          if(usertype.equalsignorecase("admin user found")){             runonuithread(new runnable() {                 public void run() {                      toast.maketext(login.this, "login sucess",                                toast.length_long).show();                   }             });               intent in=new intent(login.this, reports.class);             startactivity(in);          }            else if(usertype.equalsignorecase("no user found")){             runonuithread(new runnable() {                 public void run() {                        tv1.settext("invalid username , password");                  }              });                     }           }         }        });    } private class loadviewtask extends asynctask<void, integer, void>   {       //before running code in separate thread       @override       protected void onpreexecute()       {            progressdialog = progressdialog.show(login.this,"loading...",                   "loading application view, please wait...", false, false);         progressdialog.show();      }         @override       protected void doinbackground(void... params)       {            try           {                synchronized (this)               {                    int counter = 0;                    while(counter <= 4)                   {                        this.wait(850);                        counter++;                        publishprogress(counter*25);                   }               }           }           catch (interruptedexception e)           {               e.printstacktrace();           }           return null;       }         @override       protected void onprogressupdate(integer... values)       {            progressdialog.setprogress(values[0]);       }        @override       protected void onpostexecute(void result)       {            progressdialog.dismiss();         }    }            private boolean checkpassword(string password) {              return password_pattern.matcher(password).matches();         }          private boolean checkusername(string username) {              return username_pattern.matcher(username).matches();         }         @suppresswarnings("deprecation")         public void showalertdialog(context context, string title, string message, boolean status) {             alertdialog alertdialog = new alertdialog.builder(context).create();               alertdialog.settitle(title);               alertdialog.setmessage(message);               alertdialog.seticon((status) ? r.drawable.success : r.drawable.fail);               alertdialog.setbutton("ok", new dialoginterface.onclicklistener() {                 public void onclick(dialoginterface dialog, int which) {                 }             });               alertdialog.show();         }  } 

do not use application's context, use context view presented.

   report.setonclicklistener(new onclicklistener() {          @override         public void onclick(view v) {              intent i=new intent(v.getcontext(), login.class);             startactivity(i);         }     }); 

Comments