我有一个splash screen
,一个GridView
,一个simple text view
。
在应用程序启动时,我会显示启动画面,之后我调用“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.
在主页上,当我单击后退按钮时,我希望应用程序退出或关闭... 但由于第1页,第2页,第3页仍然在堆栈中,我不能退出应用程序。
在我的主屏幕上,如果我点击平板电脑的“主页”按钮,应用程序将退出。当我从“应用程序”选项再次启动应用程序时,将显示先前显示的屏幕,而不是启动屏幕!!!
我想让它显示启动画面。
答案 0 :(得分:2)
在您开始活动时尝试使用FLAG_ACTIVITY_NEW_TASK
。
答案 1 :(得分:1)
将该活动的清单中的启动模式用作单个任务
答案 2 :(得分:1)
使用
调用新屏幕Intent intent = new Intent(activity,secondActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivity(intent);
当您点击主页按钮时,应用程序将获得恢复。所以下次打开同一页面。用于此用途
@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
startActivity(new Intent(Activity1.this,spalshscreen.class));
}
重新启动时,如果活动在堆栈中,您还可以使用Intent.FLAG_ACTIVITY_CLEAR_TOP
重置标记。
答案 3 :(得分:1)
在您的活动中尝试此代码 -
@Override
protected void onDestroy() {
android.os.Process.killProcess(android.os.Process.myPid());
}
退出应用程序时,您的申请流程实际上并未销毁。如果你破坏你的进程,所有子进程(你所有的子线程)都将被销毁。