2012-05-24 61 views
0

我目前有一个buzztouch Android应用我从谷歌播放创建错误的一个问题是安卓:显示java.lang.NullPointerException

NullPointerException 
in BT_viewUtilities.updateBackgroundColorsForScreen() 

我已经把范围缩小到下面的代码,有没有人看到任何代码中的错误。如果你需要别的东西,请问,这可以解决不少应用程序。谢谢

//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() + "\""); 
+0

我不知道你是什么意思时,你说“范围缩小”,但这里有一个小技巧:空指针带有它告诉你在哪条线路发生问题的线路号。 – keyser

+0

'产生的原因:在com.idragracenews.BT_viewUtilities.updateBackgroundColorsForScreen(BT_viewUtilities.java:37)显示java.lang.NullPointerException ' 这里是线37 “BT_debugger.showIt(对象名+ “:与updateBackgroundColorsForScreen昵称:\” “+ theScreenData.getItemNickname()+”\“”);' – Alton

回答

2

theScreenData或BT_debugger是null。

1

我认为这是导致空点异常theScreenData.getItemNickname()

+0

你为什么会这样想,也是为什么要问我也是这样。 – Alton

2

我不知道你的代码做什么,但解决方法是简单的一行:

//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"); 
    } 
} 

要调试错误你可以这样做:

//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"); 
     } 
    } 
相关问题