Android Studio : Change Text Color time by time in OnCreate : This is my first time asking questions here.
I am trying to make my TextView text color changing to a random color time by time when the application is started.

This is what I attempted but it made my app crashed.




    TextView txtLucky;
    Random rd;
    int r = 0, g = 0, b = 0;
    Thread stopper = new Thread();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        txtLucky = findViewById(R.id.txtLucky);

        while (true){
            try {
                wait(2000);
                rd = new Random();
                int rdcolor = Color.argb(255, rd.nextInt(256), rd.nextInt(256), rd.nextInt(256));
                txtLucky.setTextColor(rdcolor);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            stopper.start();
        }
    }
