如何杀死一个活动
我有一个启动屏幕
、一个GridView
、一个简单文本视图
。
在应用程序启动时,我显示启动屏幕,然后调用“finish()”退出活动,然后启动“GridView
”活动。
1st page: Grid View having 4 buttons, let's call it Home page..
2nd page: On click of 1st button, SAME grid view is called. But this time, there are 5 buttons.
3rd page: On click of 1st button, same grid view is called. This time there are 3 buttons.
4th page: On click of 1st button, it opens a simple text view, which has a text box and an "Home" button.
在主页上,当我单击后退按钮时,我希望应用程序退出或关闭... 但由于第一页、第二页、第三页仍在堆栈中,我不能直接退出应用程序。
在我的主屏幕上,如果我点击平板电脑的“主页”按钮,应用程序就会退出。当我从“应用程序”选项再次启动应用程序时,将显示之前显示的屏幕,而不是启动屏幕!
我希望它显示启动画面。
I have a splash screen
, a GridView
, a simple text view
.
On application start, I show the splash screen after which i call "finish()" to exit the activity and then start the "GridView
" activity.
1st page: Grid View having 4 buttons, let's call it Home page..
2nd page: On click of 1st button, SAME grid view is called. But this time, there are 5 buttons.
3rd page: On click of 1st button, same grid view is called. This time there are 3 buttons.
4th page: On click of 1st button, it opens a simple text view, which has a text box and an "Home" button.
On home page, when i click the back button, I want the application to exit, or close...
But since the 1st, 2nd, 3rd page are still in the stack, I cannot just exit the application.
On my home screen, if i hit the "home" button of the tablet, the application exits. When i start the application again from the "Apps" option, the previously present screen is shown and not the splash screen!!!
I want it to show the splash screen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
启动 Activity 时尝试使用
FLAG_ACTIVITY_NEW_TASK
。try to use
FLAG_ACTIVITY_NEW_TASK
when you start the activity.使用调用新屏幕
当您点击主页按钮时,应用程序将恢复。所以下次它打开同一页面。对于重新启动时的此用途
,如果 Activity 在堆栈中,您还可以使用
Intent.FLAG_ACTIVITY_CLEAR_TOP
重置标志。Call new screen using
When you hit home button , application get resume. so next time it open the same page. for this use
on restarting , you can also reset flag using
Intent.FLAG_ACTIVITY_CLEAR_TOP
if activity is in stack.在该 Activity 的清单中使用启动模式作为单个任务
单击此处获取理解启动模式
use Launch mode in manifest for that Activity as single Task
Click Here to Get Uunderstanding For Launch Modes
在您的活动中尝试此代码 -
当您退出应用程序时,您的应用程序进程实际上并未被销毁。如果你销毁你的进程,所有子进程(你的所有子线程)都将被销毁。
try this code in your activity -
When you exit from your application, your application process is not actually destroyed. If you destroy your process, all child processes(all your child threads) will be destroyed.