开发者

Frustrating but quite common taking SNAPSHOT problem!

Taking photos using system provided component(MediaStore.ACTION_IMAGE_CAPTURE) is quit common.

As Ive 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 Im not correct and there is further info, please point it out)

However, I also found out that, when the killing occurs, all my information stored in the RAM were ERASED, RESETED, for example those Single开发者_运维百科ton class type objects, or static classes and their fields!

This mechanism is so frustrating, how to handle such situation??


I`ve found it out...

Some android OS kill the snapshot calling Activity to avoid memory related exception. So, I have to save all the states via method onSaveInstanceState, and retrieve them when the calling activity was constructed again.

Further more, I also found out that, all the information stored in the memory is prone to be erased, like those Singleton objects. Thus I have to do saving by some persistent storage approaches, and restore them later.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜