0

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 js is variable, where I put all the data like "4,5,6,23,123" etc.

Problem:

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

Any ideas?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

As per above link, it's sending data from javascript to Android native. The OP asking how to pass data from Android native to javascript function, feel free to correct my comment.
Yes the example above does start by sending JS to Native, but my point is that in his case, he should be sending his code on a new thread and in the link above there is an example of creating new threads in Android. His main issue is not the passing of the JS, it's that it's freezing his UI for a second or two. If he passes the data from a thread other than the main thread it will not freeze his UI.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.