简体   繁体   中英

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)?

I'm calling script from DroidGap class.

public class MyClass extends DroidGap

Inside MyClass I am calling:

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

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

Problem:

It sends data to javascript normally, but the UI in javascript frozes for second.

Any ideas?

You may want to try running the javascript send on a new thread. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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