parse.com - Android: ParseUser with username shown on button after login -
i implementing parseuser user management.
parseuser login:
public void signin(final view v) { v.setenabled(false); parseuser.logininbackground(musernamefield.gettext().tostring(), mpasswordfield.gettext().tostring(), new logincallback() { @override public void done(parseuser user, parseexception e) { if (user != null) { intent intent = new intent(loginactivity.this, first4.class); intent.addflags(intent.flag_activity_no_animation); startactivityforresult(intent, 0); overridependingtransition(0, 0); // 0 no animation loginactivity.this.finish(); } else { // signup failed. @ parseexception see happened. switch(e.getcode()){ case parseexception.username_taken: merrorfield.settext("sorry, username has been taken."); break; case parseexception.username_missing: merrorfield.settext("sorry, must supply username register."); break; case parseexception.password_missing: merrorfield.settext("sorry, must supply password register."); break; case parseexception.object_not_found: merrorfield.settext("sorry, credentials invalid."); break; default: merrorfield.settext(e.getlocalizedmessage()); break; } v.setenabled(true); } } }); }
first page:
// load user parseuser currentuser = parseuser.getcurrentuser(); btn_login.settext(""+ currentuser);
question:
after user has login valid username peter , password abc123, switches first4 page. show username paper on button btn_login
, however, showing com.parse.parseuser@42247001 instead of peter.
how fixed?
by doing calling default tostring()
method on parseuser
object. need retrieve name parseuser
object this:
// load user parseuser currentuser = parseuser.getcurrentuser(); btn_login.settext(currentuser.getusername());
you can see different method of object here.
Comments
Post a Comment