After close following the link : http://cocos2d-x.org/docs/manual/framework/html5/v3/reflection/en , I tried to test it on the raw hello world project. I have added the below block of code to the AppActivity.java file.
private static AppActivity app = null;
@Override
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();
}
});
}
And then in the app.js file I add the line:
jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "showAlertDialog", "(Ljava/lang/String;Ljava/lang/String;)V", "title", "hahahahha");
The code fails at the above line. I am using v3.5. How do I get out of this trouble??