简体   繁体   English

Phonegap和Android:将数据从本机发送到Javascript

[英]Phonegap and Android: Send data from Native to Javascript

What is the best way to send array of data from native code (java) to the javascript code (phonegap)? 将数据数组从本机代码(java)发送到javascript代码(phonegap)的最佳方法是什么?

I'm calling script from DroidGap class. 我正在从DroidGap类调用脚本。

public class MyClass extends DroidGap

Inside MyClass I am calling: 我在MyClass内部打电话:

MyClass.this.sendJavascript("javascript: app.basic('" + js + "'); ");

Variable js is variable, where I put all the data like "4,5,6,23,123" etc. 可变js是可变的,我将所有数据放入“ 4、5、6、23、123”等。

Problem: 问题:

It sends data to javascript normally, but the UI in javascript frozes for second. 它将数据正常发送到javascript,但是javascript中的UI却一秒钟。

Any ideas? 有任何想法吗?

You may want to try running the javascript send on a new thread. 您可能想尝试在新线程上运行javascript发送。 There is an example of creating a new thread here: 这里有一个创建新线程的示例:

http://docs.phonegap.com/en/3.0.0/guide_platforms_android_plugin.md.html#Android%20Plugins http://docs.phonegap.com/zh-CN/3.0.0/guide_platforms_android_plugin.md.html#Android%20插件

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

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