0

I didn't seem to find any related answers, SL4A version is R6, Py4A is R5. It's really simple, the app calls webViewShow with a HTML page, it displays properly, the script terminates, but the page does not want to disappear. Can't reach menu, back button doesn't work, only home button, then you need to kill sl4a from app manager if script is running through adb, or kill the script if run from the on-device interpreter. I also tried with http://www.google.com, same happening. The webViewShow returns a NoneType, but still, the page is displayed.

Example:

    import android
    droid = android.Android() 
    droid.webViewShow('/sdcard/sl4a/scripts/main_view.html'

HTML:

    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" id="viewport"
            content="width=device-width, target-densitydpi=device-dpi,
            initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
            />
      </head>
      <body >
        <h1 style="text-align:center">Supervisor</h1>

      </body>
    </html>

Thanks in advance!

3 Answers3

0

Maybe this could help:

<script>
    var droid = new Android();
</script>

<input type="button" value="Exit" onclick="droid.dismiss();" />
0

I also ran into this problem, and could not find a proper answer. In my case I suspect the script cannot fully 'terminate' until the WebView closes...catch-22. To work around it I added an explicit 'Quit' option to the phone's menu button before spawning the WebView:

# give us a way to escape from the webview
droid.addOptionsMenuItem('Quit','menu-quit',None,"ic_lock_power_off")

Not ideal (the user still has to hunt for the Quit option or know about it in advance), but seems to work taking down both the script and WebView, at least on my phone (SL4A r6, Android 2.3.7).

Drmn
  • 13
  • 2
0

i agree with pedro. this is the only way to exit a webview from sl4a, confirmed by damon kolher, the last maintainer of the project before it was finally forked.

once you deployed a webview, there is no way to kill it besides from within itself using js.

<script> var droid = new Android(); </script>

Then attach this to an element.

onclick="droid.eventPost('kill', ''); droid.dismiss();

For me I use an eventPost call back to my main script via eventWait.

while True:
    event = droid.eventWait().result
    if event['name'] == 'kill':
        pipe.send('kill')
        pipe.close()

i find this to work exceptionally well as i am using bottle to serve up my webview as two seperate processes and needed a way to shutdown my script as soon as the webview was exited.

michael g
  • 603
  • 7
  • 14