開始的時候很納悶,為什麼會這樣了,然後就搜尋了下,發現其實文檔早就告訴我了,隻不過英文差,沒看仔細。。。
原文如下:
int | START_NOT_STICKY | Constant to return from : if this service's process is killed while it is started (after returning from ), and there are no new start intents to deliver to it, then take the service out of the started state and don't recreate until a future explicit call to . |
http://developer.android.com/reference/android/app/Service.html#START_STICKY
相信大家都是知道onStartCommand是有傳回值的,這貨真心是有用的,為的是告訴系統這背景服務要怎麼存活着,其實英文不好的也可以慢慢看的,看着看着就懂了
本人遇到的問題,簡單翻譯過來就是,系統會重新開機app的服務,重新開機的時候intent就是空的,自己要做好判斷。。。