从应用程序图标pressing home键和访问应用程序再次调用的onCreate? [英] pressing home button and access app again from app icon call onCreate?

查看:87
本文介绍了从应用程序图标pressing home键和访问应用程序再次调用的onCreate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个离线,在线申请,我就发现了一个奇怪的问题,可能是没有,但我did'nt了解一下吧..
应用程序的要求是,如果网络可用,甚至无法启动应用程序或无法恢复,我称之为Web服务和SQLite中存储数据,否则程序停留在离线模式下,
我有2个活动,第二个活动包含一个ID,我通过意图传递(这一点很重要),
我的问题:
如果我的第二个活动,和网络正在运行,并且我preSS home键,那么这第二个活动暂停,然后停止其在Android中,我转到设置一个默认行为,打开wifi关闭,那么preSS应用图标重新找回我的应用程序,在这里,我糊涂了,我希望我的应用程序现在会在 onResume ,但我在logcat中看到它的 onCreated 打来电话,应用程序 崩溃,NullPointerException异常发生,因为这第二个活动没有这个ID,我路过的意图。

I have an offline-online application, i found a strange issue in it, may be it is not, but i did'nt understand about it..
App requirement is that, if internet is available, even from starting app or from resuming, i call webservices and store data in sqlite, otherwise app stays in offline mode,
I have 2 activities, second activity contains an id, that i passes through intent (that point is important),
My Problem:
if i am in second activity, and internet is running, and i press home button , then this 2nd activity pauses, then stop which is a default behavior in android, i goto settings, turn wifi off, then press app icon again to get back in my app, here i got confused, i expect that my app now will be in onResume, but when i see in logcat its onCreated called and app crashes, nullPointerException occurs, because this 2nd activity does not have that id, i passed through intent..

注意:
如果我使用最新的应用程序按钮,进入设置,然后图灵WiFi关闭后再次回来,并重复这一切的行为,那么做工精细,其onResumes叫不OnCreate中。

Note:
If i use recent app button to go to "settings", then come back again after turing wifi off, and repeat all this behavior, then working fine, its onResumes called not oncreate..

我的提问
为什么会进的onCreate而我我的期望是要onResume虽然我来自应用程序图标?

My Question
Why it is going in onCreate while i my expectation is to be onResume while i came back from app icon?

推荐答案

在您的活动的的onStop被称为它的容易被android系统收集的其他应用程序资源被杀死这是我想到的事情发生在你的case.If它被杀死,Android将明显打电话OnCreate中,当你回到activity.Check 的澄清。用于试验,你可以尝试从最近的应用程序打开多个应用程序,然后返回到您的应用程序。它可能会崩溃,有太多了。

Once your activity's onStop gets called it's susceptible to be killed by the android system to collect resources for other apps which is what i think happened in your case.If it is killed, android will obviously call OnCreate when you get back to the activity.Check this for clarification. For experimenting you can try opening more than one apps from your recent apps and then return to your app. It may crash there too now.

这篇关于从应用程序图标pressing home键和访问应用程序再次调用的onCreate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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