简体   繁体   English

onCreate被调用两次?

[英]onCreate being called twice?

Using my mom's phone with my app if i hit the home button and then navigate back to the app, it is calling onCreate again. 如果我按了主页按钮,然后将妈妈的电话与我的应用程序一起使用,然后导航回该应用程序,它将再次调用onCreate。 If I understand correctly this should not be the case right? 如果我理解正确,那应该不是这样吗?

I know this is happening because my webview loads and it should just open up the page that was already open. 我知道这是由于我的Web视图加载而发生的,它应该打开已经打开的页面。 Especially since I have the launch mode set to singleInstance... 特别是因为我将启动模式设置为singleInstance ...

What are some reasons to why it would be called twice on my mom's phone, but on my phone it works exactly how it should? 为什么在我妈妈的电话上两次调用它,但是在我的电话上它应该如何工作却又有什么原因呢?

According to the Android documentation , your Activity can be killed at any time when it's not active which is the case when you switch back to the home screen. 根据Android文档 ,当您的“活动”处于非活动状态时,您可以随时将其杀死,例如,当您切换回主屏幕时。

If an activity is paused or stopped, the system can drop the activity from memory by either asking it to finish, or simply killing its process. 如果某个活动暂停或停止,系统可以通过要求完成活动或仅删除其进程来从内存中删除活动。 When it is displayed again to the user, it must be completely restarted and restored to its previous state. 当它再次显示给用户时,必须完全重新启动并恢复到之前的状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM