应用程序崩溃长时间应用时的简历 [英] Application crashes when application resume for long time
问题描述
我创建一个Android应用程序。它拥有从服务器下载过程。它运行良好,直到应用程序运行和维护没有任何崩溃的数据,但现在我坚持了如下
I am creating an android application. It holds a downloading process from server. It's running fine until the application runs and maintains the data without any crashes, but now I am stuck up with the problem as described below
当应用程序通过pressing home键和一个很长一段时间后减少,当我打开应用程序中的所有数据都将被删除。它给了我一个空指针异常;即使ArrayList中值被删除,它给出了一个0大小的数组列表。
When the application minimizes by pressing home button and after a long time, when I open the application all the data in the application are deleted. It gives me a "Null Pointer Exception"; even the ArrayList value are deleted and it gives a 0 sized arraylist.
我只是从主屏幕通过最大化后OnResume打开应用程序,但它并没有调用自己。
I am opening the application after maximizing from the home screen through OnResume only, but it didn't call itself.
我不知道为什么会出现此问题。任何人都可以请建议我一个解决方案,并指出我什么我做错了?
I don't know why this problem occurs. Can anyone please suggest me a solution and point me what am I doing wrong?
推荐答案
是的,这是真的 - 因为@paradx说 - 垃圾收集丢弃的数据,而应用程序是在后台。最后,我找到了一个解决方案,基于@paradx建议,因为数据存储在SQLite的或savedInstanceState
Yes, it's true - as @paradx said - that the Garbage Collector throws away the data while the app is in background. Finally I found a solution based on @paradx suggestion, as data are stored in SQLite or savedInstanceState
只是通过一些静态值通过
Just pass some of static values through the
intent.putExtra("static key","static value");
然后静态HashMap的都写在一个文件中,供以后使用检索。现在,应用程序不会崩溃了这个问题。
Then static hashmap are written in a file and retrieved for later use. Now the application does not crash for this problem.
我已张贴这一解决方案,从而使他人可能会使用它。
I have posted this solution so that someone might use it.
这篇关于应用程序崩溃长时间应用时的简历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!