简体   繁体   English

后退按钮编辑操作

[英]Back button edit action

I have a splash screen and if I press the back button while the splash activity is running this activity is closed but the next activity after the splash (after 2 seconds) will be open. 我有一个启动画面,如果在启动启动时按下后退按钮,此活动将关闭,但启动后(2秒后)的下一个活动将打开。 I would like to set the back button to close the splash activity but to open immediately the next activity or to close the whole application. 我想设置后退按钮来关闭启动活动但是立即打开下一个活动或关闭整个应用程序。

You need to override the back-button with this: 你需要用这个覆盖后退按钮:

    @Override
    public void onBackPressed(){
       Intent i1 = new Intent(getApplicationContext(), NextActivity.class);
       startActivity(i1);
    return; 

This will take you to the next Activity when you pres the button. 当您按下按钮时,这将带您进入下一个活动。 If you want to close the app try this: 如果你想关闭应用程序,试试这个:

        @Override
        public void onBackPressed(){
            moveTaskToBack(true);
        return;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM