Getting user property returns null
This is the code i am using
if (Backendless.UserService.CurrentUser() != null){
// user is login
Toast.makeText(this, “Lo is user”, Toast.LENGTH_SHORT).show();
BackendlessUser user = new BackendlessUser();
String verification =String.valueOf(user.getProperties().get(“isVerified”));
String appVersion = String.valueOf(user.getProperties().get(“appVersion”));
String name = String.valueOf(user.getProperties().get(“name”));
Toast.makeText(this, "Name : "+ name + "\nApp Version : " + appVersion + "\nVerification : " + verification, Toast.LENGTH_SHORT).show();
Hi. Please show how do you receive BackendlessUser object ? Because now i see only the newly created object on the fourth line: BackendlessUser user = new BackendlessUser();
And it cannot have any of the fields you are trying to get.
@oleg-vyalyh Thank you for your time
First, I tried to confirm that the user is login
if (Backendless.UserService.CurrentUser() != null)
then by declaring the Object of a user to fetch the properties
BackendlessUser user = new BackendlessUser();
String verification =String.valueOf(user.getProperties().get(“isVerified”));
String appVersion = String.valueOf(user.getProperties().get(“appVersion”));
String name = String.valueOf(user.getProperties().get(“name”));
that are in the Users Table on the console
Let me know if you need any information from my side
Or you show me a demo how can i fetch property from the backendless that would be very helpful
Method Backendless.UserService.CurrentUser()
returns BackendlessUser
object. And if it is not null, then you already have what you need.
To retrieve user in case when it doesn’t present in the app yet, please, invoke Backendless.UserService.login()
. To create new user invoke Backendless.UserService.register()
.
Also see more information here: https://backendless.com/docs/android/users_user_registration.html
Solved the problem by declaring the user outside of the if block like
BackendlessUser user = new BackendlessUser();
user = Backendless.UserService.CurrentUser();
if (user != null){
String verification =String.valueOf(user.getProperties().get(“isVerified”));
String appVersion = String.valueOf(user.getProperties().get(“appVersion”));
String name = String.valueOf(user.getProperties().get(“name”));