android - Error login to server with volley -
i have problem login. force stop when login button click.
this code :
//initializing views edittextemail = (edittext) findviewbyid(r.id.edemail); edittextpassword = (edittext) findviewbyid(r.id.edpassword); btlogin = (button) findviewbyid(r.id.btlogin); btlogin.setonclicklistener(this); ((textview) findviewbyid(r.id.btdaftar)) .setonclicklistener(new onclicklistener() { public void onclick(view v) { loginactivity.this.startactivity(new intent(loginactivity.this,signupactivity.class)); } }); } @override protected void onresume() { super.onresume(); //in onresume fetching value sharedpreference sharedpreferences sharedpreferences = getsharedpreferences(config.shared_pref_name,context.mode_private); //fetching boolean value form sharedpreferences loggedin = sharedpreferences.getboolean(config.loggedin_shared_pref, false); //if true if(loggedin){ //we start profile activity intent intent = new intent(loginactivity.this, mainactivity.class); startactivity(intent); } } private void login(){ final string email = edittextemail.gettext().tostring().trim(); final string password = edittextpassword.gettext().tostring().trim(); stringrequest stringrequest = new stringrequest(request.method.post, config.login_url, new response.listener<string>() { @override public void onresponse(string response) { if(response.trim().equalsignorecase(config.login_success)){ sharedpreferences sharedpreferences = loginactivity.this.getsharedpreferences(config.shared_pref_name, context.mode_private); sharedpreferences.editor editor = sharedpreferences.edit(); editor.putboolean(config.loggedin_shared_pref, true); editor.putstring(config.email_shared_pref, email); editor.commit(); intent intent = new intent(loginactivity.this, mainactivity.class); intent.setflags(intent.flag_activity_clear_top); intent.putextra("exit me", true); startactivity(intent); finish(); }else{ toast.maketext(loginactivity.this, "invalid username or password", toast.length_long).show(); } } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { } }){ @override protected map<string, string> getparams() throws authfailureerror { map<string,string> params = new hashmap<>(); //adding parameters request params.put(config.key_email, email); params.put(config.key_password, password); //returning parameter return params; } }; //adding string request queue requestqueue requestqueue = volley.newrequestqueue(this); requestqueue.add(stringrequest); } @override public void onclick(view v) { login(); }
the log cat is:
11-13 06:05:07.990: e/androidruntime(13864): fatal exception: main 11-13 06:05:07.990: e/androidruntime(13864): process: com.example.mdesigntemp, pid: 13864 11-13 06:05:07.990: e/androidruntime(13864): java.lang.noclassdeffounderror: com.example.mdesigntemp.loginactivity$4 11-13 06:05:07.990: e/androidruntime(13864): @ com.example.mdesigntemp.loginactivity.login(loginactivity.java:84) 11-13 06:05:07.990: e/androidruntime(13864): @ com.example.mdesigntemp.loginactivity.onclick(loginactivity.java:134) 11-13 06:05:07.990: e/androidruntime(13864): @ android.view.view.performclick(view.java:4783) 11-13 06:05:07.990: e/androidruntime(13864): @ android.view.view$performclick.run(view.java:19887) 11-13 06:05:07.990: e/androidruntime(13864): @ android.os.handler.handlecallback(handler.java:739) 11-13 06:05:07.990: e/androidruntime(13864): @ android.os.handler.dispatchmessage(handler.java:95) 11-13 06:05:07.990: e/androidruntime(13864): @ android.os.looper.loop(looper.java:135) 11-13 06:05:07.990: e/androidruntime(13864): @ android.app.activitythread.main(activitythread.java:5290) 11-13 06:05:07.990: e/androidruntime(13864): @ java.lang.reflect.method.invoke(native method) 11-13 06:05:07.990: e/androidruntime(13864): @ java.lang.reflect.method.invoke(method.java:372) 11-13 06:05:07.990: e/androidruntime(13864): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:911) 11-13 06:05:07.990: e/androidruntime(13864): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:706)
it says error in
stringrequest stringrequest = new stringrequest(request.method.post, config.login_url, new response.listener<string>() {
i don't know fault. do mistake? every answer helpful me. in advance
update code here:
(textview)findviewbyid(r.id.btdaftar)
like:
textview tx = (textview)findviewbyid(r.id.btdaftar); tx.setonclicklistener(this);
and override onclick() method.
Comments
Post a Comment