parse.com - Android Parse "invalid session token" error -
i new android , stuck on seems simple problem fix don't know doing wrong! need sign user, reason e never equal null , therefore goes straight else part gives me invalid session token message. here code signup part, looked @ thousands of times!:
protected edittext musername; protected edittext mpassword; protected edittext memail; protected button msignupbutton; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_sign_up_manager); musername = (edittext)findviewbyid(r.id.usernamefield); mpassword = (edittext)findviewbyid(r.id.passwordfield); memail = (edittext)findviewbyid(r.id.emailfield); msignupbutton = (button)findviewbyid(r.id.signupbutton); msignupbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { string username = musername.gettext().tostring(); string password = mpassword.gettext().tostring(); string email = memail.gettext().tostring(); //trims spaces username = username.trim(); password = password.trim(); email = email.trim(); //if 1 of text edits empty send them message title ok button. if(username.isempty() || password.isempty() || email.isempty()){ alertdialog.builder builder = new alertdialog.builder(signupmanageractivity.this); builder.setmessage(r.string.signup_error_message) .settitle(r.string.signup_error_title) .setpositivebutton(android.r.string.ok, null); alertdialog dialog = builder.create(); dialog.show(); } else { setprogressbarindeterminatevisibility(true);//the progress circle active. //creating new parse user. parseuser puser = new parseuser(); puser.setusername(username); puser.setpassword(password); puser.setemail(email); puser.signupinbackground(new signupcallback() { @override public void done(parseexception e) { setprogressbarindeterminatevisibility(false);//the progress circle not active. if (e == null) { intent intent = new intent(signupmanageractivity.this, loginmanageractivity.class); intent.addflags(intent.flag_activity_new_task); intent.addflags(intent.flag_activity_clear_task); startactivity(intent); } else { alertdialog.builder builder = new alertdialog.builder(signupmanageractivity.this); builder.setmessage(e.getmessage()) .settitle(r.string.signup_error_title) .setpositivebutton(android.r.string.ok, null); alertdialog dialog = builder.create(); dialog.show(); } } }); } } }); }
please help, in advance!
first post here had same error. correct me if wrong believe issue me create user once , invalid session tokens afterwards. think due fact "session" on parse website's end still logged in though can close , re-run app on end.
by putting following code before try create new parse user fixed issue.
parseuser currentuser = parseuser.getcurrentuser(); currentuser.logout();
hope helps. cheers!
Comments
Post a Comment