简体   繁体   English

将Android活动中的Java变量传递给phonegap应用程序中的javascript

[英]Pass java variables from Android activity to javascript in phonegap application

I am developing cross platform applications that target Android, iOS, Blackberry and Windows Phone Platforms. 我正在开发针对Android,iOS,Blackberry和Windows Phone平台的跨平台应用程序。 I am using Jquery Mobile 1.3.1, jquery 1.9.1 and Phonegap 2.8.0. 我正在使用Jquery Mobile 1.3.1,jquery 1.9.1和Phonegap 2.8.0。

I want to be able to pass variables from an Android activity to javascript. 我希望能够将变量从Android活动传递给javascript。

How can I call a javascript function from an activity and also call a method in java from javascript. 如何从活动中调用javascript函数以及如何从javascript中调用Java中的方法。

I browsed for a solution, but, could not understand the usage of sendJavascript() and loadUrl() . 我浏览了一个解决方案,但无法理解sendJavascript()loadUrl()的用法。

Could someone please help me Understand this. 有人可以帮我理解这一点。 I am new to Android and cannot understand how to get this done. 我是Android的新手,无法理解如何完成此操作。

Thanks in advance. 提前致谢。

Solution is : Phonegap plugin. 解决方法是 :Phonegap插件。

A Phonegap plugin bridges a bit of functionality between the WebView powering a Cordova application and the native platform the Cordova application is running on. 一个Phonegap插件在驱动Cordova应用程序的WebView和运行Cordova应用程序的本机平台之间架起了一些功能。

It is well explained with each platform in official phonegap doc.Here you can read more about Android plugin of phonegap . 大家都在官方的PhoneGap每个平台doc.Here你可以阅读更多有关解释的PhoneGap的Android插件 And here a very nice tutorial on how to Write a PhoneGap 3.0 Plugin for Android . 这里有一个非常不错的教程, 介绍如何编写适用于Android的PhoneGap 3.0插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM