之后,点击一个按钮关闭活动叠加 [英] Closing activities stack after a button click

查看:79
本文介绍了之后,点击一个按钮关闭活动叠加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,从我做起,从我的登陆页面,其中的数据是从第1步一路传递到第8步。为了保持数据完整,同时还在步骤之间,我不是要求完成八步向导 ()在任一活动。但是,当所有的步骤后,是没有办法,我可以关闭所有8个活动我已经开始并返回到登陆页面?一个方法

各种各样的图例位置:

首页 - 第1步 - > 2 - > 3 - > 4 - > 5 - > 6 - > 7 - > 8

在这一点上,当用户点击保存,关闭所有的步骤(8),并返回到首页。我一直在创造一个新的意向要做到这一点,到目前为止,但我知道这是不是最好的解决方案。一个简单的回preSS带他回到了7步。

任何帮助AP preciated。

解决方案

 意向意图=新的意图(这一点,Home.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(意向);
 

这将杀死之间的所有活动从8日的屏幕,并启动您坎屏幕的背面。还ü可以设置乌拉圭回合主屏幕的acitivty清单中launchmode =singleTop。看到此链接 - <一个href="http://developer.android.com/guide/topics/fundamentals.html#acttask">developer.android.com/guide/topics/fundamentals.html#acttask

In my app, I start an eight step "wizard" from my landing page in which data is passed from step 1 all the way to step 8. For keeping the data intact while still in between steps, I am not calling finish() on either of the activities. However, when all the steps are complete, is there a way that I can close all the 8 activities I had started and return back to the landing page?

An illustration of sorts here:

Home - Step 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8

At this point, when the user clicks "Save", close all the Steps (8) and go back to the Home Page. I have been creating a new intent to do this so far, but i realize this is not the best solution. A simple back press takes him back to the 7th Step.

Any help appreciated.

解决方案

Intent intent = new Intent(this, Home.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

This will kill all the activities in between from your 8th screen and launch your hom screen back. also u can set ur home screen's acitivty in manifest launchmode="singleTop". see this link - developer.android.com/guide/topics/fundamentals.html#acttask

这篇关于之后,点击一个按钮关闭活动叠加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆