I read the doc http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html
It extends DrawableContainer which seen like a kind of UI, and it implements Runnable, so it should run in a new thread (It should right? since it implements Runnable). Then in this case, should we follow the rule "only update UI component in UI thread"?
I have tested a program that perform a heavy loop after AnimationDrawable.start(), and program crashs (with famous stop responding error). Now I am totally confused, is AnimationDrawable.start() run in new thread?
Edit:
AnimationDrawable.start();
for (int i = 0 ; i< 10000000 ; i ++){
System.out.println(i);
}
Now I know why it implements Runnable :
new Thread(){
public void run(){
AnimationDrawable.start();
}
}.start();
for (int i = 0 ; i< 10000000 ; i ++){
System.out.println(i);
}
I thought after I dispatch the start()
to new thread, it will run in a new thread and not causing any "no responding error", but in fact it still crashes. Now I know it implements Runnable because Android posts it back to the UI thread to execute.