哪种方法时,Home键pressed运行? [英] Which method is run when Home button pressed?

查看:218
本文介绍了哪种方法时,Home键pressed运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从您可以在其中推出一些应用程序的主页更换活动。当您点击主页按钮,您将返回到我的家庭更换活动。

据我了解,攻的主页按钮创建一个意图,启动主屏幕,然后启动一个意图(我可能是错的,请纠正我,如果我在这里!)。如果是这样的话,我期望每当创建主屏幕要运行的的onCreate()方法。在另一方面,当您启动另一项活动,在主页屏幕上调用的onPause()。于是久违这让我假设 onResume()被调用。

如果有人可以只提供一些启示此事,基本的问题是,是否 onResume()的onCreate()得到,当我轻按Home键调用,但其他细节是受欢迎的,我工作的东西,利用该严重,想知道了很多关于它。


解决方案

  

攻的主页按钮创建一个意图,启动主屏幕,然后启动一个上故意


正确的。


  

如果是这样的话,我期望每当创建主屏幕要运行的onCreate()方法


不一定。如果它已经运行,它将与被称为 onNewIntent()


  

如果有人可以只提供一些启示此事,基本的问题是,是否onResume()或OnCreate()中,当我点击Home键被调用


任何时候,任何活动从用户输入的角度来看返回前台, onResume()被调用。主屏幕应该在这方面没有什么不同。

的onCreate()创建活动时,被称为的。现有的活动不创造,而只是带回前台。如果是什么触发了活动返回到前台是一个 startActivity()调用,该活动将与 onNewIntent() onResume()(通常在onStart(),对于这个问题)。

I have a Home replacement Activity from within which you can launch a number of apps. When you tap the Home button, you are returned to my Home replacement Activity.

As I understand, tapping the Home button creates an intent to launch the Home screen and then starts that intent (I might be wrong, please correct me if I am!). If this is the case, I'd expect the onCreate() method to be run whenever the Home screen is created. On the other hand, when you launch another activity, the Home screen invokes onPause(). So returning to it makes me assume onResume() is invoked.

If someone could just offer some enlightenment into this matter, the basic question is whether onResume() or onCreate() gets called when I tap the Home button, but additional details are welcome, I'm working on stuff that utilizes this heavily and want to know a lot about it.

解决方案

tapping the Home button creates an intent to launch the Home screen and then starts that inten

Correct.

If this is the case, I'd expect the onCreate() method to be run whenever the Home screen is created

Not necessarily. If it is already running, it would be called with onNewIntent().

If someone could just offer some enlightenment into this matter, the basic question is whether onResume() or onCreate() gets called when I tap the Home button

Any time any activity returns to the foreground from a user input standpoint, onResume() is called. Home screens should be no different in this regard.

onCreate() is called when the activity is created. Existing activities are not created, but are merely brought back to the foreground. If what triggered the activity to return to the foreground was a startActivity() call, the activity will be called with onNewIntent() and onResume() (and usually onStart(), for that matter).

这篇关于哪种方法时,Home键pressed运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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