Android: java.lang.NullPointerException

182 Views Asked by At

I am currently have a problem with a buzztouch android app I created the error from google play is

NullPointerException
in BT_viewUtilities.updateBackgroundColorsForScreen()

I have narrowed it down to the following code, does anyone see any kind of error in the code. If you need something else please ask, this would fix quite a few apps. Thank you

//updates a screens background colors and image...
public static void updateBackgroundColorsForScreen(final Activity theActivity, final          BT_item theScreenData){
BT_debugger.showIt(objectName + ":updateBackgroundColorsForScreen with nickname: \"" +     theScreenData.getItemNickname() + "\""); 
3

There are 3 best solutions below

0
On

Either theScreenData or BT_debugger is null.

1
On

I think this is the line that causes null point exception-theScreenData.getItemNickname()

0
On

I have no idea what your code is doing but the fix is simple:

//updates a screens background colors and image...
public static void updateBackgroundColorsForScreen(final Activity theActivity, final BT_item theScreenData){
     if(BT_debugger != null && theScreenData != null){
          BT_debugger.showIt(objectName + ":updateBackgroundColorsForScreen with nickname: \"" +     theScreenData.getItemNickname() + "\""); 
     } else {
         Log.e("YourApp", "Warning null var, command not completed");
     }
}

To debug the error you could do:

    //updates a screens background colors and image...
    public static void updateBackgroundColorsForScreen(final Activity theActivity, final BT_item theScreenData){
         if(BT_debugger != null){
             if(theScreenData != null){
                BT_debugger.showIt(objectName + ":updateBackgroundColorsForScreen with nickname: \"" +     theScreenData.getItemNickname() + "\""); 
             } else {
                Log.e("YourApp", "theScreenData was null, command not completed");
             }
         } else {
             Log.e("YourApp", "BT_debugger was null, command not completed");
         }
    }