android - How to Call javascript function by webview? -


i have 2 message when call invokescriptmethod("showpoll(" + device.pollid + ");"); , not work!

message in logcat 1-firewall not null 2-euler: isurlblocked = false

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_poll);          device.webviewshowpoll = (webview) findviewbyid(r.id.webviewshowpoll);           device.webviewshowpoll.getsettings().setjavascriptenabled(true);             device.webviewshowpoll.getsettings().setpluginsenabled(true);                device.webviewshowpoll.getsettings().setjavascriptcanopenwindowsautomatically(true);     device.webviewshowpoll.getsettings().setallowfileaccess(true);     device.webviewshowpoll.addjavascriptinterface(appconnector, "appconnector");      try     {         device.webviewshowpoll.loaddatawithbaseurl("file:///android_asset/",                 utility.convertstreamtostring(getassets().open("application.html",                         assetmanager.access_buffer)), "text/html", "utf-8","");              }      catch (ioexception e)     {         log.e(getstring(r.string.app_name), e.getmessage());     } }     public static void invokescriptmethod(string method) {      device.webviewshowpoll.loadurl("javascript:" + method); }  public static void invokescript(string script) {     device.webviewshowpoll.loadurl(script); }     public void bt_click(view v) {     invokescriptmethod("showpoll(" + device.pollid + ");"); } 

and androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.omid.epoll.mobile" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="16" />  <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.set_debug_app"/> <uses-permission android:name="android.permission.write_external_storage" />     <uses-permission android:name="android.permission.access_network_state" />     

may line of code helps :webview.getsettings().setpluginstate(pluginstate.on);


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -