web app with qpython an SL4A in android
<p>I am new to python on android and I am trying to buid the small example of a web application found here ( <a href="http://pythoncentral.io/python-for-android-using-webviews-sl4a/" rel="nofollow">http://pythoncentral.io/python-for-android-using-webviews-sl4a/</a> ) where a python script opens a web page and communicates with it (you enter a text in the web page and the python script process it and send it back to the web page for display). In my attempt to do this the python script can open the page but there is no dialog between the web page and the script. It seems that the line " var android = new Android() " in the web page doesn't work as in the example.</p>

<p>Here is the code for the webpage :</p>

<pre><code>&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;script&gt;
            var droid = new Android();

            function postInput(input) {
                if (event.keyCode == 13)
                    droid.eventPost('line', input)

                droid.registerCallback('stdout', function(e) {
                    document.getElementById('output').innerHTML = e.data;
                });
            }
        &lt;/script&gt;   
    &lt;/head&gt; 
    &lt;body&gt;
        &lt;div id="banner"&gt;
            &lt;h1&gt;SL4A Webviews&lt;/h1&gt;
            &lt;h2&gt;Example: Python Evaluator&lt;/h2&gt;
        &lt;/div&gt;

        &lt;input id="userin" type="text" spellcheck="false"
               autofocus="autofocus" onkeyup="postInput(this.value)"
        /&gt;

        &lt;div id="output"&gt;&lt;/div&gt;

        &lt;button id="killer" type="button"
                onclick="droid.eventPost('kill', '')"
        &gt;QUIT&lt;/button&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>and the python code launching the web page above :</p>

<pre><code>import sys, androidhelper
droid = androidhelper.Android()

def line_handler(line):
    ''' Evaluate user input and print the result into a webview.
    This function takes a line of user input and calls eval on
    it, posting the result to the webview as a stdout event.
    '''
    output = str(eval(line))
    droid.eventPost('stdout', output)

droid.webViewShow('file:///storage/emulated/0/com.hipipal.qpyplus/scripts/webview1.html')

while True:
    event = droid.eventWait().result

    if event['name'] == 'kill':
        sys.exit()
    elif event['name'] == 'line':
        line_handler(event['data'])
</code></pre>

<p>I really don't understand how the Android() instance in the web page was supposed to work. Thank you for any help !
(I am running qpython with SL4A library on android lollipop)</p>