Support Topics Documentation Slack YouTube Blog

NullPointerException AFTER logging in

(Yuval Rafitkes) #1

Hi there
Was working on my app and tried to login via backendless as an account - something that worked perfectly so far.
but now (without even touching this class), it is causing me a NullPointerException and crashes my app.
wired thing is - the debugger sends me inside the handleResponse method:

my code:
` findViewById( View.OnClickListener() {
public void onClick(View view) {
String uName = ((EditText)findViewById(;
String uPass = ((EditText)findViewById(;

            Backendless.UserService.login(uName, uPass, new AsyncCallback<BackendlessUser>() {
                public void handleResponse(BackendlessUser response) {

        ? true : false;
                   if ((boolean) response.getProperty("isAdmin")) {
                        startActivity(new Intent(context, AdminActivity.class));
                        Log.e("admin activity","went to admin");
                    } else {
                        Intent intent = new Intent(context, ClientActivity.class);
                        intent.putExtra("name", response.getProperty("name").toString());
                        Log.e("client activity","went to client");


what im getting:

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
    at com.hackeru.mybackendless.MainActivity$1$1.handleResponse(
    at com.hackeru.mybackendless.MainActivity$1$1.handleResponse(

when line 97 is -
if ((boolean) response.getProperty(“isAdmin”)) {

any help?

(Saad Zahoor) #2

well i am also new to this platform but i guess you should try

if (response.getProperty("isAdmin")){
}else {

if statement will check if the condition is true or not if true then if block will execute and if not then else will

(Vladimir Yalovy) #5

Hi @Yuval_Rafitkes

Check the properties: response.getProperties() or response.containsKey(“isAdmin”), it may be empty or does not contain the key “isAdmin” (BackendlessUser properties is HashMap).

(Yuval Rafitkes) #6

thank you all for you help. it happen to be an api key typo (may have clicked by mistake on refresh at some point and the one in the db didn’t match the one in the app). truly appreciate the effort, everything works perfectly now.

Have a great day!