2011-03-24 55 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对象一样。因此,我必须通过一些持久性存储方法进行保存,并在稍后恢复。