How to call another activity after certain time limit

后端 未结 4 1526
遥遥无期
遥遥无期 2021-02-06 03:09

How to give time limit for calling one activity to another activity. I want to call another activity (Ex calling A class to B class) by given some time limit. I used alarmManage

4条回答
  •  我在风中等你
    2021-02-06 03:39

    Here is a simply solution. this could be used for example for showing a splash activity for 1 second then going into the main app:

    public class Splash extends Activity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.splash);
    
                int secondsDelayed = 1;
                new Handler().postDelayed(new Runnable() {
                        public void run() {
                                startActivity(new Intent(Splash.this, ActivityB.class));
                                finish();
                        }
                }, secondsDelayed * 1000);
        }
    }
    

提交回复
热议问题