完成所有活动的时间 [英] Finish all activities at a time
问题描述
我是新来的Android和想提出一个应用程序的多个页面,即多个活动,但有些活动保持开放。如何关闭所有活动的一次......
I am new to android and am making an application with multiple pages i.e. multiple activities but some activities remain open. How to close all activities at once...
推荐答案
每当你想退出所有打开的活动,你应该preSS一个按钮,加载运行在第一个活动当你应用程序启动,然后清除所有其他活动,然后让剩余的最后一个活动完成。 这样做可以应用下面的code在乌拉圭回合项目
Whenever you wish to exit all open activities, you should press a button which loads the first Activity that runs when your application starts then clear all the other activities, then have the last remaining activity finish. to do so apply the following code in ur project
Intent intent = new Intent(getApplicationContext(), FirstActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("EXIT", true);
startActivity(intent);
以上code完成除FirstActivity所有活动。 然后,我们需要完成FirstActivity的 中输入以下code Firstactivity的OnCreate
The above code finishes all the activities except for FirstActivity. Then we need to finish the FirstActivity's Enter the below code in Firstactivity's oncreate
if (getIntent().getBooleanExtra("EXIT", false)) {
finish();
}
和你做......
这篇关于完成所有活动的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!