I'm new to driodscript and i find your work on building android apps awesome!
I'm writing my first app and my problem is i need to pass data from webview.Execute() to the main droidscript app.
I've tried declaring a global variable in the droid script app and setting the variable in the webview.Execute method. Like this
//////////////////////////////
Var data;
Function OnStart(){
//...
Web.Execute("data='blah'");
app.ShowPopup(data);
}
///////////////////////////////
I would highly appreciate your help
Any variable inside the webview is contained only in that webview, and not available to your app, or the other way around.
Globals included.
You're example sets a variable in the webview, but it won't be available to your app.
a = 'Hello';
web.Execute('a = "'+a+'";');
For dynamic inputs, etc... there are many ways.... just remember scope.
If your webview is local (not a url) add:
<script src='file:///android_asset/app.js'></script>
Then you can use DS methods inside your webview, but most importantly, you can send vars back or run functions from your app.
Example... say you have a html button in your webview, you can use an onclick handler to run a function in your app.
onclick="app.Execute('myFunction()');"
Hope that helps :)