-1

当手机通过监听 Boot_completed 事件重新启动时,我有一个接收器来做出反应。在接收器中,我确实使用了应用程序中的一些数据。我的意思是我检查一些条件。喜欢:

if(getWordsNumber()>0)
{
    do sth;
}

但是当我重新启动手机时,它总是会崩溃。问题是 NullPointerException。任何人都知道如何处理这个?是否可以在不打开应用程序的情况下使用数据进行一些检查?

错误信息:

08-02 01:35:11.224: E/AndroidRuntime(3194): FATAL EXCEPTION: IntentService[wcc]
08-02 01:35:11.224: E/AndroidRuntime(3194): java.lang.NullPointerException
08-02 01:35:11.224: E/AndroidRuntime(3194):     at com.wcc.features.alarmnotification.WCCNotificationServiceReview.isShowNotification(WCCNotificationServiceReview.java:36)
08-02 01:35:11.224: E/AndroidRuntime(3194):     at com.wcc.features.alarmnotification.WCCNotificationServiceBase.onHandleIntent(WCCNotificationServiceBase.java:34)
08-02 01:35:11.224: E/AndroidRuntime(3194):     at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
08-02 01:35:11.224: E/AndroidRuntime(3194):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-02 01:35:11.224: E/AndroidRuntime(3194):     at android.os.Looper.loop(Looper.java:154)
08-02 01:35:11.224: E/AndroidRuntime(3194):     at android.os.HandlerThread.run(HandlerThread.java:60)

代码

public boolean isShowNotification() {
    // TODO Auto-generated method stub
    int reviewCount = WCCWordCardAndListData.getInstance().wccWordsForListReview.size();
    if(reviewCount >0)
        return true;
    else
        return false;
}
4

1 回答 1

0

任何一个

WCCWordCardAndListData.getInstance()

或者

wccWordsForListReview

一片空白。最简单的判断方法是在调试器中单步执行并查看这些变量的值是什么。

于 2013-08-01T17:42:01.737 回答