Guys, in all the activations the transitions work with animation, but in one activity, where I have a timer for execution, the animation does not work.

package com.example.com.shcherbuk; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import java.util.Timer; import java.util.TimerTask; public class StartActivity extends AppCompatActivity implements Constants { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_start); startApp(); } private void startApp(){ Timer myTimer = new Timer(); // Создаем таймер myTimer.schedule(new TimerTask() { // Определяем задачу @Override public void run() { Intent intent=new Intent(getApplicationContext(),WebActivity.class); intent.putExtra(KEY_INTENT,URL_MY_WEBSITE); //Запуск Браузера //startActivity(intent); //Запуск Main startActivity(new Intent(getApplicationContext(),MainActivity.class)); overridePendingTransition(R.anim.slide_in_right,R.anim.slide_out_left); //finish(); } }, 3L * 1000); } } 

Why doesn’t animation work here when moving from one activity to another, and how to solve this problem?

    1 answer 1

    Threads helped solve this problem. Here is the code:

     new Handler().postDelayed(new Runnable() { @Override public void run() { startActivity(new Intent(getApplicationContext(),MainActivity.class)); overridePendingTransition(R.anim.slide_in_right,R.anim.slide_out_left); } }, 3*1000);