Current user returns Null || Android

Do you still get false in response to Backendless.UserService.isValidLogin ?

yes I still get false

Could you please also show the code of your login method?

Backendless.UserService.login(name, pass, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser backendlessUser) {
progressbar.dismiss();
startActivity(new Intent(LogIn.this, MainActivity.class));
}

@Override
public void handleFault(BackendlessFault backendlessFault) {
    login.dismiss();
    Toast.makeText(getApplication(), backendlessFault.getMessage() + backendlessFault.getCode(), Toast.LENGTH_SHORT).show();
}

}, true);

After login, can you retrieve the current user ID with Backendless.UserService.loggedInUser() ?

in the
main activity ?

Anywhere in the code after successful login.

For example:

Backendless.UserService.login(name, pass, new AsyncCallback&lt;BackendlessUser&gt;() {
@Override
public void handleResponse(BackendlessUser backendlessUser) {
String currentUserId = Backendless.UserService.loggedInUser();
progressbar.dismiss();
startActivity(new Intent(LogIn.this, MainActivity.class));
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
login.dismiss();
Toast.makeText(getApplication(), backendlessFault.getMessage() + backendlessFault.getCode(), Toast.LENGTH_SHORT).show();
}
}, true);

Yes I can …I displayed it in Toast Message

Well, I can’t see it in your Toast Message.

Is it null or it has some value?
Try also to exit the application, then enter it and retrieve this value again. Has it changed?

it is not null

Even after reentering the application?

yeah

Okay, then now you can retrieve current user by his ID.

Backendless.UserService.findById( currentUserId, asyncCallback )

No wait…After I login the toast which contain the id displays “null”

if I get out of the app then re enter (without remove the app from recent app )

the id is shown in the toast (not null )

I don’t know why … but sometimes it’s null and some times there is value !!!

OK, we’ll recheck this functionality and notify you here about the results.

Ok thanks … and sorry for taking your time …

Now …I can get the id but the setCurrentUser method isn’t working

That is the code :

if(Id != null){
Toast.makeText(this,Id,Toast.LENGTH_LONG).show();
Backendless.UserService.findById(Id,
new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser backendlessUser) {
Backendless.UserService.setCurrentUser(backendlessUser);
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
}
});
}else{
Toast.makeText(getApplication(),“no user”,Toast.LENGTH_SHORT).show();
startActivity(new Intent(MainActivity.this, LogIn.class));
}