android怎么样来意图之间切换 [英] android How to switch between Intents

查看:108
本文介绍了android怎么样来意图之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个活动。启动/游戏/结束,我想去开始游戏,游戏结束,完成启动。但是当我使用意向另一个人当我完成()完成它回来比赛。它应该回过头来启动。所以它需要设计一种所有意图开始活动之下。

I have 3 activities. start / game / finish, I want to go start to game, game to finish, finish to start. but when I use Intent one to another when I finish() "finish" Its come back to game. It should come back to start. so It needs a design kind of all Intents under start activity.

所以我想这个和预期,当我完成()完成应用程序将被破坏,但它没有工作。

so I tried this one and expected when I finish() "finish" application will be destroy but It didnt work

Intent intent = new Intent(getApplicationContext(),FinishScreen.class); 
startActivity(intent);

问:所以我怎么能在活动开始而是从游戏活动开始结束活动意图

Q: so how can I start finish activity Intent under start activity but from game activity

推荐答案

当你调用 startActivity(...)在游戏活动启动完成活动,立即拨打完成()这样的游戏终止。如果你这样做,然后在完成活动将返回到开始,因为游戏自我终止。

When you call startActivity(...) in "game" Activity to start the "finish" Activity, immediately call finish() so "game" terminates. If you do that then BACK in the "finish" Activity will return to "start" because "game" self-terminated.

Intent intent = new Intent(getApplicationContext(),FinishScreen.class); 
startActivity(intent);
finish();

这篇关于android怎么样来意图之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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