问题描述
我开发一个Android应用程序与PhoneGap的2.9.0,我想实现一个特殊的功能,但我不知道该怎么做。
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.
我想使用Android 如果我在Java code执行一个功能,我想是的PhoneGap执行特定的功能。
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.
但我没有找到任何方法如何做到这一点。我刚刚找到了如何从PhoneGap的数据发送到Java,但是我正在寻找其他方式。
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!
推荐答案
从扩展CordovaActivity您的活动在
From inside your Activity extending CordovaActivity
this.appView.sendJavascript("window.mySpecialFunction()");
或从PhoneGap的插件里面
Or from inside a PhoneGap Plugin
this.webView.sendJavascript("window.mySpecialFunction()");
显然,你会替换你需要的任何功能的字符串,你必须建立必要到JS字符串以及任何数据。
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.
这篇关于从执行的Java的Android功能的PhoneGap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!