0

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() + "\""); 
piokuc
  • 25,594
  • 11
  • 72
  • 102
Alton
  • 3
  • 5
  • I don't know what you mean when you say "narrowed it down" but here's a tip: the nullpointer comes with a line number which tells you at which line the problem occurred. – keyser May 24 '12 at 19:35
  • 'Caused by: java.lang.NullPointerException at com.idragracenews.BT_viewUtilities.updateBackgroundColorsForScreen(BT_viewUtilities.java:37)' here is line 37 'BT_debugger.showIt(objectName + ":updateBackgroundColorsForScreen with nickname: \"" + theScreenData.getItemNickname() + "\"");' – Alton May 24 '12 at 23:00

3 Answers3

2

Either theScreenData or BT_debugger is null.

Kevin Mangold
  • 1,167
  • 8
  • 21
2

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");
         }
    }
Blundell
  • 75,855
  • 30
  • 208
  • 233
1

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

DeepakAndroid
  • 137
  • 1
  • 8