JavaScript Working When Access From Internet But Not Responding When Access Page From Folder Assets On WebView Android -
i try access page url : demo face tracker using android webview. , using code:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); wv = (webview) findviewbyid(r.id.webview); wv.setwebchromeclient(new webchromeclient()); wv.setwebviewclient(new webviewclient(){ @override public void onpagefinished(webview view, string url) { super.onpagefinished(view, url); } }); wv.getsettings().setjavascriptenabled(true); wv.addjavascriptinterface(new webappinterface(this), "android"); wv.loadurl("http://auduno.github.io/clmtrackr/clm_image.html"); }
and works!
but when copy of page (include javascript) local, , access form assets folder app return not responding.
this code use access local assets:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); wv = (webview) findviewbyid(r.id.webview); wv.setwebchromeclient(new webchromeclient()); wv.setwebviewclient(new webviewclient(){ @override public void onpagefinished(webview view, string url) { super.onpagefinished(view, url); } }); wv.getsettings().setjavascriptenabled(true); wv.addjavascriptinterface(new webappinterface(this), "android"); wv.loadurl("file:///android_asset/index.html"); }
for information, of assets (scripts, css, etc) except media has combined single page , when access browser (on computer) working, not in android webview.
whether on android has special permission this? please :) thank you.
most have pathing issue. might not loading think does. try adding see
@override public void onloadresource(webview view, string resurl) { super.onloadresource(view, resurl); log.d(log_tag,"loading " + resurl); }
add setallowuniversalaccessfromfileurls address javascript security issue when loading file.
wv.getsettings().setallowuniversalaccessfromfileurls(true);
Comments
Post a Comment