大家好 : )
想請教各位前輩開發widget時有沒有遇到過
"一開始update與一般運作都正常,但一段時間過後widget就被打回原型
(預設的layout),且完全不能點不能動" 的狀況呢@@??
因使用自己的手機做測試一直沒有發生類似的問題,所以沒有錯誤報告可以參考...
這兩天也用了各種想到的關鍵字去google,找出以下可能的狀況:
1. 將onUpdate裡的動作移到Service執行,可避免它來不及做完
但若是使用者一開始有一段時間的update是可以正常執行的話,
是不是表示這段在onUpdate裡面的code並不會太長呢...?
還是是我鴕鳥心態解讀錯誤了... :p
2. 爬了板上的文章發現可能有pendingIntent flag設錯的問題(?)導致widget不能點,
檢查程式碼之後確定flag設定應是正確的...
又回到一直覺得 "使用者一開始有一段時間可以正常使用" 的鴕鳥點@@
3. google發現有可能是當手機記憶體不足時,appwidget provider被 "殺死" (?!)
但這個狀況... 不才的原PO實在看不懂最後網友解決的方法是什麼 囧
:) well I did that eventually, but i was thinking it to be a bad hack. I
actually have 3 entities a WakeAliveService in my code, a WidgetUpdateService
and the AppWidgetProvider. WakeAliveService sends periodic broadcasts which
are picked up by the WidgetUpdateService to update the widgets in a list
stored in ApplicationClass. AppWidgetProvider updates the list with ids in
OnUpdate / OnDelete. When the widget id is updated the list is saved back to
prefs. When Application starts again the list is read. On a reboot this list
is cleared. DO you think this is a right approach ?
想請教大家不知有沒有類似的開發經驗可以分享呢@@...
也跪求關於上面英文的解讀 T^T
呼~~ 真的還有很長一段的學習路要走 : )
先說聲謝謝大家 <(_ _)>
感恩~~~~