javascript - Html button click event detection in Android webview -


hi getting html button click event in android webview side.its work fine when html file inside android asset folder when have used html page online url it's android keywords not found in javascript code. here's code

//webview android addjavascriptinterface  webview.addjavascriptinterface(new webappinterface(this), "android");  public class webappinterface {     context mcontext;     webappinterface(context c) {         mcontext = c;     }     @javascriptinterface     public void getviewid(string result) {         log.d("sid", "click-----------" + result);     } } 

my html , js code

</head> <body>     <button onclick="saveid('122');">1</button>     <button onclick="saveid('222');">2</button>     <img onclick="saveid('imgclickevent')" src="file:///android_res/drawable/dtech.png"/> </body> 

<script language="javascript">    function saveid(_id){  //android keyword not found how solve ?     android.getviewid(_id);   } </script> 

i found solution above question. android (android.getviewid(_id)) keyword work on when javascript inside in html page not external js file.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -