4

im porting my project in AndEngine GLES2, with GLES1 versione i use this tutorial to load assets in background, now i receive this error:

mActivity.onCreateScene failed. @(Thread: 'GLThread 10')
java.lang.ExceptionInInitializerError

This is my onCreateScene method

    @Override
    public Scene onCreateScene() {
        this.mEngine.registerUpdateHandler(new FPSLogger());
        SplashScene mSplashScene = new SplashScene(this);

        IAsyncCallback callback = new IAsyncCallback() {

            @Override
            public void workToDo() {
            //Do something}

            @Override
            public void onComplete() {
                LoadingScene mLoadingScene = new LoadingScene(mActivity.this);
                mActivity.this.getEngine().setScene(mLoadingScene);
            }
        };

        new AsyncTaskLoader().execute(callback);

        return mSplashScene;
    }
Matteo
  • 2,029
  • 4
  • 22
  • 30

1 Answers1

5

Change

new AsyncTaskLoader().execute(callback);

to

    //Fixed variant working with gles1 and gles2
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new AsyncTaskLoader().execute(callback);
        }
    });
dimetil
  • 3,851
  • 2
  • 29
  • 47
  • Hi Recently i found that ICS is not supporting Runnable in normal android app do above code make problem when we use this in andengine... – Renjith K N Dec 11 '12 at 17:53