中的消息。它將錯誤顯示爲空指針異常:println需要android中的消息e。我試圖將代碼從改變:在我的谷歌雲消息應用程序中,println需要android
Log.e("UnRegister Receiver Error", "> " + e.getMessage());
到:
String err = (e.getMessage()==null)?"UnRegister Receiver Error":e.getMessage();
Log.e("UnRegister Receiver Error", err);
,但它仍然是相同的error.please幫助我。
@Override
protected void onDestroy() {
if (mRegisterTask != null) {
mRegisterTask.cancel(true);
}
try {
unregisterReceiver(mHandleMessageReceiver);
GCMRegistrar.onDestroy(this);
} catch (Exception e) {
//String err = (e.getMessage()==null)?"UnRegister Receiver Error":e.getMessage();
//Log.e("UnRegister Receiver Error", err);
Log.e("UnRegister Receiver Error", "> " + e.getMessage());
}
super.onDestroy();
}
的logcat:
02-28 22:58:35.254: E/AndroidRuntime(2812): FATAL EXCEPTION: IntentService[GCMIntentService-414538748674-1]
02-28 22:58:35.254: E/AndroidRuntime(2812): java.lang.NullPointerException: println needs a message
02-28 22:58:35.254: E/AndroidRuntime(2812): at android.util.Log.println_native(Native Method)
02-28 22:58:35.254: E/AndroidRuntime(2812): at android.util.Log.d(Log.java:138)
02-28 22:58:35.254: E/AndroidRuntime(2812): at com.example.fitness2.GCMIntentService.onRegistered(GCMIntentService.java:29)
02-28 22:58:35.254: E/AndroidRuntime(2812): at com.google.android.gcm.GCMBaseIntentService.handleRegistration(GCMBaseIntentService.java:296)
02-28 22:58:35.254: E/AndroidRuntime(2812): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:197)
02-28 22:58:35.254: E/AndroidRuntime(2812): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
02-28 22:58:35.254: E/AndroidRuntime(2812): at android.os.Handler.dispatchMessage(Handler.java:99)
02-28 22:58:35.254: E/AndroidRuntime(2812): at android.os.Looper.loop(Looper.java:137)
02-28 22:58:35.254: E/AndroidRuntime(2812): at android.os.HandlerThread.run(HandlerThread.java:60)
02-28 22:58:35.422: W/EGL_emulation(2812): eglSurfaceAttrib not implemented
02-28 22:58:35.774: V/GCMRegistrar(2812): Unregistering receiver
02-28 22:58:35.774: E/UnRegister Receiver Error(2812): Receiver not registered: [email protected]
02-28 22:58:35.774: E/UnRegister Receiver Error(2812): > Receiver not registered: [email protected]
嗯,嗯,我沒有看到logcat日誌中的onDestroy ...你沒有提供代碼與日誌中的堆棧跟蹤 – Selvin