Android – ViewRootImpl$CalledFromWrongThreadException

I got the same problem trying to change UI view from c++ using JNI. The solution was use

runOnUiThread(new Runnable() {
    public void run(){   
    }
});

runOnUiThread is an Activity method so I have to make my activity instance public static to be able to call on my public static method who later call from JNI.

Hope this help others 🙂

PS: from here I learn how to use JNI http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_use_jni for my android game previously made with cocos2dx

Leave a Comment