I'm in this code I am cycling through an attaylist of objects and assigning each object a callback, yet when I get to using a CountDownTimer, it crashes with Can't create handler inside thread that has not called Looper.prepare()
for ( final ABoxActor a : actList )
{
ActorDamageListener adl = new ActorDamageListener(){
public void ActorDestroyCallback() {
Log.e("KILLED", a.getBitmapName() );
}
public void ActorDamageCallback(float damage) {
Log.e("DAMAGED "+String.valueOf(damage), a.getBitmapName() );
a.setSpriteCurrentFrame(10);
//// THROWS Can't create handler inside thread that has not called Looper.prepare()
CountDownTimer t = new CountDownTimer(500,500){
@Override
public void onFinish() {
a.setSpriteCurrentFrame(15);
}
@Override
public void onTick(long millisUntilFinished) {
}}.start();
/////////////////////////////////
}
};
a.setListener(adl);
}
Any ideas what would be the easiest way to fix that? Can I somehow add this "looper" to my callback definition?
Thanks!