-5

I want to start a new activity after a period of time on button click, but the problem is there that first i want to recreate the A.activity than to start B.activity after a period of seconds.

animation2.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {

            en.setVisibility(View.VISIBLE);
            al.setVisibility(View.VISIBLE);

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

  en.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            locale = new Locale(" ");
            Locale.setDefault(locale);
            Configuration config = new Configuration();
            config.locale = locale;
            getBaseContext().getResources().updateConfiguration(config,
                    getBaseContext().getResources().getDisplayMetrics());
            LanguageActivity.this.recreate();


            startActivity(new Intent(LanguageActivity.this, ServicesActivity.class));
        }
    });
Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Endar
  • 63
  • 3
  • 10

1 Answers1

0

I want to start a new activity after a period of time on button click

    en.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //...
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    startActivity(new Intent(LanguageActivity.this, ServicesActivity.class));
                }
            }, 5 * 1000); // 5 seconds
        }
    });
MarcGV
  • 1,242
  • 1
  • 10
  • 33