I am trying to login with an user in Parse, but when I use the login Parse function I get the error "java.lang.IllegalStateException: ParseObject has no data for this key. Call fetchIfNeeded() to get the data. ". This is a bit strange, because I have never had this error before when I login. I have not change any ParseUser. The code to login is the same that you can find in Parse Documentation.
ParseUser.logInInBackground(nombre, pass, new LogInCallback() {
public void done(final ParseUser user, ParseException e) {
if (user != null) {
// Hooray! The user is logged in.
} else {
// Signup failed. Look at the ParseException to see what happened.
e.printStackTrace();
}
}
});
StackTrace:
.IllegalStateException: ParseObject has no data for this key. Call fetchIfNeeded() to get the data.
04-18 12:15:28.611 27662-27662/droidotech.com.adaptavision W/System.err﹕ at com.parse.Parse$4$1.run(Parse.java:790)
04-18 12:15:28.612 27662-27662/droidotech.com.adaptavision W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:725)
I have solved the problem. In another class, I have a String value that call a get function in its declaration. You can not do this, you must call get function in the constructor or init method.
This is wrong:
private String TITLE = "This is the title" + getTitle();
This is the correct way:
private String TITLE;
public void init(String title){
TITLE = "This is the title" + title;
}