android - Set a backround timer to change the color randomly -


i have view , need change color of every x seconds.

i want decide when can start , stop timer.

this must done in background not block ui thread.

@baptistem, instead of using asynctask can use handler , runnable this,

private void startcolortimer() {     mcolorhandler.postdelayed(colorrunnable, interval);     timeron = true; }  private handler mcolorhandler = new handler();  private runnable colorrunnable = new runnable() {      @override     public void run() {         coloredtextview.settextcolor(getrancolor());          if (timeron) {             mcolorhandler.postdelayed(this, interval);         }     } }; 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -