2

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.

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)

How to do that?

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 ?

4

5 回答 5

5

为什么不使用 Splash 2 的启动活动代码覆盖活动 A 上的后退按钮?我认为这是唯一的解决方案。

例如:

@Override
public void onBackPressed() {
   Intent setIntent = new Intent(ActivityA.this, Splash2.class);
   startActivity(setIntent);
   finish();
}
于 2012-04-16T10:34:52.730 回答
1

简单到

  1. 使用 startActivityForResult 方法从启动中调用您的活动 A 而无需调用完成

  2. 覆盖 splash 的 onActivityResult 以显示结束闪屏

于 2012-04-16T10:38:19.323 回答
1

取决于您希望用户何时退出。如果它仅在 Activity A 中,您可以简单地在那个中覆盖 onKeyDown,否则在您获得的每个 Activity 中覆盖它。

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
        startActivity(new Intent("com.android.splashscreen"));
        finish();
    }
}

创建并启动您的结束启动画面。

于 2012-04-16T10:43:12.830 回答
1

您可以覆盖 finish() 方法,添加 startActivity。

于 2012-04-16T10:33:23.963 回答
0

Activity A 的 override 方法onBackPressed()。在这里面你可以开始你的闪屏 2/END 活动。

于 2012-04-16T10:37:20.987 回答