Sunday, 15 July 2012

How to call java script in android? -



How to call java script in android? -

i new java script using in android,i have function in js file convert user name,how send i/p values , how retrieve info file in android activity button click.if 1 have thought please tell me in advance.

tru out :

public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); web = (webview) findviewbyid(r.id.webview1); web.setwebchromeclient(new mywebchromeclient()); web.addjavascriptinterface(new demojavascriptinterface(), "temp_1"); web.loadurl("file:///android_asset/temp_1.html"); } } final class demojavascriptinterface { private handler mhandler = new handler(); webview web; demojavascriptinterface() { } public void clickonandroid() { mhandler.post(new runnable() { public void run() { web.loadurl("javascript:init();"); } });

} }

final class mywebchromeclient extends webchromeclient { private static final string log_tag = "webviewdemo"; @override public boolean onjsalert(webview view, string url, string message, jsresult result) { log.e(log_tag, message); result.confirm(); homecoming true; } }

android

No comments:

Post a Comment