I'm trying to play a gif using the Movie
object and it requires me to call the invalidate()
method. However whenever I call this method I get the following error:
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
How do I fix this and why is it happening
Runs the specified action on the UI thread.
I would like to recommend read this site runOnUiThread
runOnUiThread(new Runnable() {
@Override
public void run() {
// call the invalidate()
}
});