Hi Backendlesses!
can’t seem to be able to update the current users’ properties.
I get an error 1001 with my code:
first I define the user variable :
BackendlessUser user = Backendless.UserService.CurrentUser();then in the ocCreate I define the backendless details: String appVersion = “v1”;
Backendless.initApp(this, “bla bla real number hidden”, “bla bla also hidden”, appVersion);
then I try to update in this methode:
public void userVpressed (View view){
user.setProperty(“about”, “a great guy”);
Backendless.UserService.update( user, new AsyncCallback<BackendlessUser>()
{
public void handleResponse( BackendlessUser user )
{
// user has been updated, return to user profile
Intent intent = new Intent( UserEditActivity.this, UserActivity.class );
startActivity( intent );
}
public void handleFault( BackendlessFault fault )
{
// user update failed, to get the error code call fault.getCode()
Toast.makeText(UserEditActivity.this, fault.getCode(), Toast.LENGTH_LONG).show();
}
});
}
I get an error 1001.
why ? what does it mean ?
thanks!
Here’s the code I just tried with the jar file from the SDK download available on the website right now. It works as expected. Could you try it with the same code? Make sure to change the email address and password in the login call:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Backendless.initApp(this, "my app id here", "my secret key", "v1");
loginUser();
}
private void loginUser()
{
AsyncCallback<BackendlessUser> loginCallback = new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser backendlessUser) {
Log.i( "MY APP", "User logged in" );
updateCurrentUser();
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
Log.e( "MY APP", backendlessFault.getMessage() );
}
};
Backendless.UserService.login( "mark@backendless.com", "password", loginCallback );
}
private void updateCurrentUser()
{
AsyncCallback<BackendlessUser> updateCallback = new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser backendlessUser) {
Log.i( "MY APP", "User has been updated" );
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
Log.e( "MY APP", backendlessFault.getMessage() );
}
};
BackendlessUser currentUser = Backendless.UserService.CurrentUser();
currentUser.setProperty( "about", "a great guy" );
Backendless.UserService.update( currentUser, updateCallback );
}
Perhaps, that’s the reason for the error. I was testing with a user objects registered directly in Backendless (without Facebook login). Unfortunately, I do not my environment configured with a facebook app for testing. I will assign this to an engineer to investigate further.
just to be sure, when I use the facebook login, I don’t need to also use the users’ email and password in each activity in the app ? I only login once in my MainActivity into facebook and use the initApp in the other activities ?
it appears it is a bug on the server side. The bug is manifested only with the use-case when user is logged in with Facebook. As a workaround (just to get you going) you could create users with Backendless console and use the Backendless.UserService.login method (like in my example). Once the bug is fixed, you will switch back to Facebook.
Mark I have a theory.
I tried changing a users’ “about” property. Maybe it didn’t work because facebook uses the same Field in the graph API?
Can’t test it till tomorrow night though. At work.
Hi, Gil. There was an issue in Android SDK that is already fixed and is going through testing process.
We’ll notify you when it’s ready. Thanks for reporting!