I use Rhino in android to execute JavaScript function code in Android (java) and get the result from this code, but I got this exception
01-22 11: 33: 57.063: E / AndroidRuntime (29175): caused by: java.lang.UnsupportedOperationException: cannot load this type of class file
This is my code.
String test = "function abc(x,y) {return x+y;}";
org.mozilla.javascript.Context context = org.mozilla.javascript.Context.enter();
try {
ScriptableObject scope = context.initStandardObjects();
Scriptable that = context.newObject(scope);
Function fct = context.compileFunction(scope, test, "script", 1, null);
Object result = fct.call(context, scope, that, new Object[] { 2, 3 });
Log.i("JML...Info", "jajajajaj = " + org.mozilla.javascript.Context.jsToJava(result, int.class));
} finally {
org.mozilla.javascript.Context.exit();
}
I got a method exception
Function fct = context.compileFunction (scope, test, "script", 1, null);
I wrote this code in the onCreate () method after loading webview, and I use rhino1_7R2.jar as a jar for Rhino.
Please help me, and if you know any other way to get value from JavaScript (return value of function) in android, please advice.
thank