How to pass a value/variable from an android java class to javascript/.html file in android 4.4.2 kitkat -


i need pass value/variable (e.g. integer, string) java class .html file inside android assets. let's integer value based on user's click. need pass this integer .html file(scripts) determine ajax call made (via if-else loop). googled everywhere couldn't find answer this.

i need achieve on android 4.4.2. in advance.

have seen http://developer.android.com/guide/webapps/webview.html? interested in binding javascript code android code section. first declare interface, implement method return integer. inside js code call method value.

edit

interface working js:

public class webappinterface {     context mcontext;      /** instantiate interface , set context */     webappinterface(context c) {         mcontext = c;     }      /** value */     @javascriptinterface     public int getvalue() {         return value     } } 

add interface webview:

webview webview = (webview) findviewbyid(r.id.webview); webview.addjavascriptinterface(new webappinterface(this), "android"); 

inside js code:

var value = android.getvalue(); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

angularjs - ng-repeat duplicating items after page reload -