我刚刚在我的项目中实现了 Pushbots 库。如果我的应用程序正在运行,推送通知效果很好。但是,如果应用程序没有运行,它总是会崩溃。我使用了 logcat,它说如下:
09-26 02:40:28.143: E/AndroidRuntime(18464): FATAL EXCEPTION:
IntentService[GCMIntentService--1]
09-26 02:40:28.143: E/AndroidRuntime(18464): java.lang.NullPointerException
09-26 02:40:28.143: E/AndroidRuntime(18464): at
com.pushbots.push.Pushbots.regID(Pushbots.java:409)
09-26 02:40:28.143: E/AndroidRuntime(18464): at
com.pushbots.push.Pushbots.sendStatsToServer(Pushbots.java:282)
09-26 02:40:28.143: E/AndroidRuntime(18464): at
com.pushbots.push.GCMIntentService.onMessage(GCMIntentService.java:112)
09-26 02:40:28.143: E/AndroidRuntime(18464): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:191)
09-26 02:40:28.143: E/AndroidRuntime(18464): at
android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
09-26 02:40:28.143: E/AndroidRuntime(18464): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-26 02:40:28.143: E/AndroidRuntime(18464): at
android.os.Looper.loop(Looper.java:137)
09-26 02:40:28.143: E/AndroidRuntime(18464): at
android.os.HandlerThread.run(HandlerThread.java:60)
09-26 02:40:28.143: E/PowerManagerService(2116): WakeLock : binderDied()
如何修复此 NullPointerException?