Hi I have followed this tutorial http://cocos2d-x.org/docs/manual/framework/html5/v3/reflection/en but I am not able to send message back to JS.
I have added the class Cocos2dxJavascriptJavaBridge inside org.cocos2dx.javascript package of the project but my app crashes when executing at this point.
code below is
package org.cocos2dx.javascript;
import org.cocos2dx.Test1.R;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
public class AppActivity extends Cocos2dxActivity {
private static AppActivity app = null;
@Override
public Cocos2dxGLSurfaceView onCreateView() {
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
// TestCpp should create stencil buffer
glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
return glSurfaceView;
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = this;
}
public static void showAlertDialog(final String title,final String message) {
//we must use runOnUiThread here
app.runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog alertDialog = new AlertDialog.Builder(app).create();
alertDialog.setTitle(title);
alertDialog.setMessage(message);
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//we must use runOnGLThread here
app.runOnGLThread(new Runnable() {
@Override
public void run() {
Cocos2dxJavascriptJavaBridge.evalString("cc.log(\"JavaScript Java bridge!\")");
}
});
}
});
}
});
}
}