开始新的活动,当用户点击"返回]从另一项活动 [英] Start new activity when user click "Back" from another activity

查看:119
本文介绍了开始新的活动,当用户点击"返回]从另一项活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在应用程序的启动画面中的活动。 启动画面已经完成(),所以用户不会看到启动画面了,当他们preSS BACK从上保持活动。但是,而不是应用程序直接退出,我希望应用程序显示一个退出闪屏具有不同的图像比启动画面后,该应用程序会直接结束。

I have a splash screen activity at the startup of app. the startup splash screen has finish(), so user will not see startup splash screen anymore when they press BACK from the last remain activity. But instead of app directly exit, I want the app show a exit splash screen which has different images than startup splash screen, after that the app will directly end.

所以,我希望它是这样的: 闪屏1(开始) - >活动A - > b活动 - >(preSS返回) - >显示活动A - >(preSS然后再返回) - >开机画面2(完)

So I want it to be like this : Splash screen 1(Beginning) -> Activity A -> Activity B -> (Press Back) -> Show Activity A -> (Press Back Again) -> Splash screen 2 (End)

如何做到这一点?

我一定要重写后退按钮在活动A或有另一种方法来显示新的活动时,用户preSS回活动的按钮?

Do I have to override back button on Activity A or there's another method to show new activity when user press back button on Activity A ?

推荐答案

你为什么不重写回活动一个按钮启动活动$ C $下飞溅2?我认为这是唯一的解决方案。

Why don't you override back button on Activity A with starting activity code for Splash 2? I think this is the only solution.

例如:

@Override
public void onBackPressed() {
   Intent setIntent = new Intent(ActivityA.this, Splash2.class);
   startActivity(setIntent);
   finish();
}

这篇关于开始新的活动,当用户点击"返回]从另一项活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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