简体   繁体   English

当用户单击主屏幕上的应用程序图标时,如何设置已经运行的活动

[英]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.

相关问题 用户在主屏幕上设置小部件时如何打开活动? - How to open activity when user will set widget on home screen? 如何检查活动是从通知启动还是从用户单击 android 中的主屏幕仪表板应用程序图标启动 - how to check whether the activity was launched from notification or from the user click on home screen dashboard app icon in android 用户单击主页按钮时终止活动 - Killing the activity when user clicks the home button 如何以编程方式在主屏幕应用程序图标android中设置徽章编号? - How set badge number in home screen app icon android programatically? 如何使Activity在主屏幕上运行? - How to make Activity running on the home screen? 如果用户已经将我的应用设置为HomeScreen,是否有简单的方法来切换Home Activity? - If the user has already set my app as HomeScreen, is there an easy way to switch the Home Activity? 如何在主屏幕上设置 Fire TV“图标”? - How to set the Fire TV “icon” on home screen? 当用户单击 HOME 按钮时显示 PIN 屏幕 android - show PIN screen when user clicks HOME button android 如何在 Android TV 主屏幕上为当前正在运行的任务设置图标和标题 - How to set the icon and title on Android TV home screen for the currently running task 如何在用户点击通知时启动活动? - How to start activity when user clicks a notification?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM