I am writing an Android “web” app (I will not upload the APP to the web, but set the HTML+JS inside the application resources). That means, the GUI will be HTML5, and I will use another “native” thread to read from the microphone and hopefully send the “parsed text” to the HTML5/JS code.
Is this possible? In the Android code, I see how can I call native code from JS (and I want the opposite).
Yes, Android rocks at this actually.
I’m posting example code from a random example app that I made but this should get you going.
Lets start by supposing you have to global variable to your webview controlling class:
In the Android class controlling the webview (during
onCreate()or when you setup your webview):Inner class to your webview controlling class:
Thats it for the Android side, now to use it through Javascript:
To get the name and lastname through JavaScript:
If you want to raise the toast, set a javascript whose function would be:
Edit:
I havent tried this, but a search yielded this, try it out, it should work.
If you want to use it in the other direction:
JS:
Android: