-
Notifications
You must be signed in to change notification settings - Fork 47
Protocoder dev
Protocoder works using Mozilla Rhino to expose Java APIs to Javascript.
If you want to expose you're own classes its pretty simple!
Extend your class from JInterface and add it class prefixed with J inside the com.makewithmoto.apprunner.api package, then add a couple of lines in the SCRIPT_PREFIX inside the AppRunnerActivity.java.
Something like
var JConsole = Packages.com.makewithmoto.apprunner.api.JConsole; var console = JConsole(Activity);
You'll be ready to rock.
If you want to have callbacks in Javascript create your methods in Java such as
public void exposedMethod(String param1, String callbackfn) { callback(callbackfn, "valuetoreturn1", "valuetoreturnN"); }
So this translated to Javascript will be something like
function exposedMethod("hello" function(data) { console.log("i just got valuetoreturn1 and valuetoreturnN" + data1 + " " + data2); });