作者GhostMonkey (疯狂上班族~~)
看板AndroidDev
标题Re: [问题] GCM离线接收讯息,当掉
时间Thu Feb 14 01:28:11 2013
小弟在此附上我的程式码:
https://gist.github.com/anonymous/3156a03c53f8aed5fdb6
V/GCMBaseIntentService(4691): Releasing wakelock
W/dalvikvm(4691): threadid=11: thread exiting with uncaught exception (group=0x40a3a1f8)
E/AndroidRuntime(4691): FATAL EXCEPTION: IntentService[GCMIntentService-764872454773-1]
E/AndroidRuntime(4691): java.lang.NullPointerException
E/AndroidRuntime(4691): at com.booya.vague.utils.NotificationMsg.emitMessage(NotificationMsg.java:29)
E/AndroidRuntime(4691): at com.booya.vague.GCMIntentService._processSayHi(GCMIntentService.java:104)
E/AndroidRuntime(4691): at com.booya.vague.GCMIntentService.onMessage(GCMIntentService.java:45)
E/AndroidRuntime(4691): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)
E/AndroidRuntime(4691): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
E/AndroidRuntime(4691): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(4691): at android.os.Looper.loop(Looper.java:137)
原因我大概知道,因为我目前的用法是在app一啓动,就利用当下的Activity产生的
Notification Service注册给NotificationMsg这个Singleton的_barManager,
所以在app执行的过程中接收讯息显示在_barManager上面都没问题,但一但从背景移除
这应用程式,就会发生_barManager为null的情况,请问各位高手是怎麽应对这种状况?
※ 引述《GhostMonkey (疯狂上班族~~)》之铭言:
: 大家好,我是Android开发者新手
: 我目前GCM处理状况都正常,只有在将它从背景移除後,若有讯息经由notification
: 传送过来,就会造成app停止回应的状况,请问这种情况要怎麽能够成功接收此
: notification呢? 谢谢大家。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.168.84.120
1F:推 changyuheng:IntentService 的生命周期有处理好吗? 02/14 04:14
2F:→ GhostMonkey:看来是没有去处理@@,我修改看看 02/16 00:51