WebView and app.js

180 views
Skip to first unread message

vaso tapiko

unread,
Dec 30, 2014, 1:45:20 PM12/30/14
to androi...@googlegroups.com
hi everyone,
 i have question about webview.

______________

JS:

 function OnStart(){
   lay = app.CreateLayout( "linear", "VCenter,FillXY" );
   web = app.CreateWebView( 1, 1 );
   lay.AddChild( web );
   app.AddLayout( lay );
   web.LoadUrl( "a.html" );
 }

HTML:

 <html>
  <head>
   <script src="file:///android_asset/app.js"></script>
  </head>

  <body style="background-color: #ffaaaa ">
   <button onclick="app.WriteFile('/sdcard/awftest.txt', 'hello');" > save </button>
  </body>

 </html>

_____________

   when i run this in DroidScript IDE everything is OK, it saves txt file.   when i'm building apk and run it does not save :((
is it bug?

Dave Smart

unread,
Dec 30, 2014, 2:05:58 PM12/30/14
to androi...@googlegroups.com
Hi Vaso,

This problem is due to the fact that DroidScript currently only scans .js files when checking for the security permissions needed for the APK build.  You can work around this problem by including a commented line in your main .js file which has the app.WriteFile() call in it.

Try putting the following line at the top of your main js file:-

//Force file write permissions in APK: app.WriteFile()


Regards
David

vaso tapiko

unread,
Dec 30, 2014, 3:08:22 PM12/30/14
to androi...@googlegroups.com
Works! Thank you :)
Reply all
Reply to author
Forward
0 new messages