2011-03-24 176 views
1

使用系統提供的組件(MediaStore.ACTION_IMAGE_CAPTURE)拍攝照片很常見。令人沮喪但很常見的SNAPSHOT問題!

正如我ve experimented, with a certain rate the android system will kill the snapshot calling Activity to prevent memory related exception, and the calling activity will be created again where returned. Thus I have to save the states of the calling Activity via onSaveInstanceState, and retrieve them via onRestoreInstanceState. (If I中號不正確,而且有進一步信息,請指出來)

不過,我也發現,當殺戮發生時,存儲在RAM中的所有我的信息被擦除,RESETED,例如那些Singleton類類型的對象,或靜態類及其字段!

這種機制是如此令人沮喪,如何處理這種情況?

回答

0

我發現了它...

一些android操作系統殺死快照調用Activity以避免內存相關的異常。所以,我必須通過方法onSaveInstanceState保存所有狀態,並在調用活動再次構建時檢索它們。另外,我還發現,存儲在內存中的所有信息都容易被擦除,就像那些Singleton對象一樣。因此,我必須通過一些持久性存儲方法進行保存,並在稍後恢復。