[英]how to Set already running activity, when user clicks on app icon on home screen
I have Two activities One splash screen, Player screen. 我有两个活动,一个启动屏幕,一个播放器屏幕。
When user clicks on my app icon first splash screen is displayed and then player screen 当用户单击我的应用程序图标时,首先显示启动屏幕,然后显示播放器屏幕
When player activity is running, if user returns to the home screen and then again clicks on app icon, the application is starting from the splash screen again. 当播放器活动在运行时,如果用户返回主屏幕,然后再次单击应用程序图标,则该应用程序将再次从初始屏幕启动。
can any one please help me out how to do any one of below 谁能帮我解决下面的任何一项吗
1) I need to close current running activity and reload application. 1)我需要关闭当前正在运行的活动并重新加载应用程序。 or 2) I need to resume to the player screen directly.
或2)我需要直接恢复播放器屏幕。
Please give me an example or reference to follow, Im beginner in android programing 请给我一个例子或参考,我是android编程的初学者
Thanks In advance 提前致谢
You may want to overrive the onRestart()
method - it will be invoked if your Activity has been stopped previously; 您可能想覆盖
onRestart()
方法-如果先前已停止您的Activity,则将调用该方法; while it won't if it's the first time it runs (or if it has effectively been killed in the meantime). 但如果是第一次运行,则不会(或者在此期间它实际上已被杀死)。
Be sure to read the Activity life cycle there: 确保在那里阅读“活动”生命周期: http://developer.android.com/guide/topics/fundamentals.html#lcycles to understand what happens when.
http://developer.android.com/guide/topics/fundamentals.html#l循环了解何时会发生什么。
Check out the order in which the life cycle states appear. 检查生命周期状态显示的顺序。 You could override onStart, onPause, onResume, onStop, onCreate, onDestroy etc functions by adding Toasts to see the sequence.
您可以通过添加Toast来查看序列来覆盖onStart,onPause,onResume,onStop,onCreate,onDestroy等函数。 Then you can override them as per your programming requirements.
然后,您可以根据编程要求覆盖它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.