I have created a timer that change my layout color every 5 seconds,but there is an error coming mentioned in title .
I have tried using runonuithread , handler but nothing seems to work
Handler refresh = new Handler(Looper.getMainLooper());
    refresh.post(new Runnable() {
        public void run()
        {
            colorchange();
        }
    });    
    private void colorchange() {
        final Timer t = new Timer();
        t.scheduleAtFixedRate(new TimerTask() {
            @Override
            public void run() {
                rl = findViewById(R.id.am);
                int[] androidColors = getResources().getIntArray(R.array.androidcolors);
                int randomcolor = androidColors[new Random().nextInt(androidColors.length)];
                rl.setBackgroundColor(randomcolor);
            }
        },0,5000);
    }