android - Caused by: java.lang.IllegalArgumentException: value may not be null. when putting data in ParseObject -


i following course on udemy , i'm on section created anonymous user , after activity, tried set anonusername put method in parseobject. above error in title when use:

put("riderusername", parseobject.getcurrentuser().getusername()); 

but "com.parse.parseuser...." when use:

put("riderusername", parseobject.getcurrentuser()); 

this code when press button send parse:

public void togglesearch(view view){      parseobject request = new parseobject("requests");     request.put("requestusername", parseuser.getcurrentuser().tostring());      parseacl acl = new parseacl();     acl.setpublicwriteaccess(true);     acl.setpublicreadaccess(true);      request.setacl(acl);      request.saveinbackground(new savecallback() {         @override         public void done(parseexception e) {             if(e == null){                 driverstatus.settext("searching drivers...");             } else {                 driverstatus.settext("error");                 e.printstacktrace();             }         }     });  } 

and created anon user in first activity:

if(parseuser.getcurrentuser() == null) {         parseanonymousutils.login(new logincallback() {             @override             public void done(parseuser user, parseexception e) {                 if (e == null) {                     log.i("app data", "logged in");                 } else {                     log.i("app data", "not logged in");                 }             }         });     } 

tried searching couldn't find anything. hoping there might else knows i'm doing wrong. thank you.

if understand correctly, can

put("riderusername", parseobject.getcurrentuser()); 

without problems, 1 fails , throws exception:

put("riderusername", parseobject.getcurrentuser().getusername()); 

of course, parseobject.getcurrentuser() not null because can store , because parseobject.getcurrentuser().getusername() throw java.lang.nullpointerexception

so, possibility user name stored in current user null.

check user name not null in login callback parameter parseuser user. can use method:

parseuser.getusername() 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -