问题
I'm developing an Android App with Phonegap 2.9.0 and I would like to implement a special function but I don't know how to do it.
I want to use an Android Status Notifications and if I execute a function in the Java Code, I want that Phonegap executes a special function.
But I don't find any method how to do this. I just found how to send data from Phonegap to the Java, but I'm looking for the other way around.
I hope you can help me. Thanks!
回答1:
From inside your Activity extending CordovaActivity
this.appView.sendJavascript("window.mySpecialFunction()");
Or from inside a PhoneGap Plugin
this.webView.sendJavascript("window.mySpecialFunction()");
Obviously you would replace the string with whatever function you needed and you'd have to build any data needed into the js string as well.
来源:https://stackoverflow.com/questions/20531184/execute-phonegap-function-from-android-java