处理DVM杀死你的活动 [英] Handling DVM killing your activity

查看:89
本文介绍了处理DVM杀死你的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个巨大的取集从网络数据的一个活动,我要处理的场景此活动若DVM决定摧毁这个活动(由于内存不足的情况​​)我没有获取相同从网络再次数据。我怎么去这样做this.please建议。

I have an activity which fetches huge set of data from the network and i want to handle the scenario for this activity if the DVM decides to destroy this activity (due to low memory condition) i don't have to fetch the same data again from the network. How do i go about doing this.please suggest.

问候,
库马尔

Regards, Kumar

推荐答案

根据数据,你需要救世主,你可以在传递数据(如果它的基本类型)到活动的套件,覆盖的的的onPause方法活动。每当活动关闭的onPause方法将被调用。

Depending on the data you need to savior you could pass in the data (if it's primitive types) into the Bundle of the Activity and override the onPause method of the activity. The onPause method will be called whenever the Activity closes.

请参阅参考 http://developer.android.com/活动的生命周期参考/安卓/应用/ Activity.html

有其他的方式来保存数据 - 你可以直接把它写在SD卡上的文件,然后在的onPause方法关闭流如果该活动是由操作系统关闭没有完成数据

There are other ways to save the data - you could write it directly to a file on the SD card and then close the stream in the onPause method if the Activity is closed by the OS without finishing the data.

那么活动开启时再次调用活动的onResume方法和读取保存的捆绑或写入到SD卡里面的文件中的数据。

Then when the Activity is opened again you call the onResume method of the Activity and read the data saved inside the Bundle or the file written to the SD card.

这篇关于处理DVM杀死你的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆