Android 中的应用程序启动
我们可以通过两种方式启动应用程序,第一种是从应用程序中,单击设备后退按钮,直到到达 Android 主屏幕并启动应用程序,第二种是从应用程序中,我们可以单击设备主页按钮,然后我们可以启动。
我们如何区分这些与发布?在第二种类型启动中,将调用 onrestart,在其他情况下也会调用 onrestart。
我想在第二种类型的发布中做一些事情。
任何人都可以告诉我如何做到这一点...
提前致谢。
We can launch the app in two ways, 1 is form the app, clicking on device back button till we reach the android home screen and launching the app or 2nd is from the app we can click the device home button and then we can launch.
How can we differentiate these to launches? In 2nd type launch onrestart will be called, onrestart will be called in some other cases also.
I want to do something in the 2nd type of launch.
Can any one tel me how to do this...
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当谈到活动启动时会发生什么时,您可能需要查看开发者网站中的以下链接。
http://developer.android.com/reference/android/app/Activity .html#ActivityLifecycle
您可能希望根据活动的生命周期进行编码,而不是根据主页键与后退键将应用程序推送到后台。应用程序被推到后台或关闭的原因可能有多种。这是处理应用程序事件的预期方式。
When it comes to what happens when the activity is started, you may want to look at the following link in the developer site.
http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle
You may want to code based on the lifecycle of the activity rather than if the application was pushed to the background by the home key vs. by the back key. There could be different reasons the application was pushed to the background or closed. This is the expected way to handle application events.