Execute Phonegap function from Android Java

跟風遠走 提交于 2020-02-07 05:05:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!