sharing everything

Android Sent Text To JavaScript

While developing Android application, sometimes we need to use webview and want our android (java code) communicate with html in webview. We can use javascript to communicate between java to html and vice versa. Dont forget to setting javascript enabled in our webview to true.

Please check code below to check how Android sent text to javascript :

Create file index.html code in assets directory. This is the contents from this html Android sent text to javascript file

Dont forget to create javascript file with name myscript.js and save to assets directory. This javascript is the important part, becuase used to communicate between java android and javascript (webview).

Please check below image for output Android sent text to javascript code :

This is a simple tutorial how Android sent text to javascript and how to javascript or webview sent text to Android. I hope this tutorial can help you solve your problem. You can download the compete code Android sent text to javascript in here.

Source : http://www.cuelogic.com/blog/simple-android-java-javascript-bridge/

My name is Toto Sugito. This is my notes when I try something. Maybe, this is NOT THE BEST SOLUTION for your problems. If you have other method or idea that better with my post, please share in this blog. Thank for visiting my site.

No Comments Yet

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Categories

Bloggers - Meet Millions of Bloggers