Resolve Error NoneType Qpython, AndroidWebView Sl4a

0

Good morning.

I have a problem I have these two files.

try:
  import androidhelper as android 
except:
  import android
droid = android.Android()
droid.webViewShow('file:///sdcard/WebViewPython/index.html')
while True: 
  result = droid.waitForEvent('say').result 
  print(str(result['data']))

HTML file:

    <html> 
   <head> 
      <title>Text To Speech</title> 

      <script> 
         var droid = new Android(); 
         var speak = function(){ 
            droid.postEvent("say",document.getElementById("say").value); 
         } 
      </script> 

   </head>

   <body> 
      <form onsubmit = "speak()";return false;”> 
         <label for = "say">What is your message?</label> 
         <input type = "text" id = "say"/> 
         <input type = "submit" value = "Speak"/> 
      </form> 
   </body> 

</html>

The problem is that it triggers an error, I have the screen with the text but once I enter a text, the screen changes to a text "null", deletes the controls and in the console I have this error.

  

/data/user/0/org.qpython.qpy/files/bin/qpython-android5.sh   "/storage/emulated/0/WebViewPython/webviewsimple.py" & amp; exit   WebViewPython / webviewsimple.py "& exit <   java.lang.NullPointerException: throw with null exception Traceback   (most recent call last): File   "/storage/emulated/0/WebViewPython/webviewsimple.py", line 9, in          print (str (result ['data'])) TypeError: 'NoneType' object has no attribute '__ getitem __' 1 | HWRNE: / $

I do not understand the error, it's as if I did not manage to send the data in result ['data'] but still it triggers the event, with something.

Thank you.

    
asked by onerom 06.11.2018 в 15:39
source

0 answers