I am using Timer to check a condition periodically and want to remove background if found true condition. But it is giving me an error.
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
My code is :
t.schedule(new TimerTask(){
@Override
public void run() {
if(!active){
fl.setBackgroundResource(android.R.color.transparent);// this line causing error !
}
}}, 500,500);