android - File not found exception on webview - when in real the file exists -
i trying load webpage in webview, getting following exception:
java.io.filenotfoundexception: https://fonts.googleapis.com/css?family=roboto:400,300,500,700,900,700italic 02-05 18:52:44.497 5263-6265/com.rm w/system.err: @ com.android.okhttp.internal.http.httpurlconnectionimpl.getinputstream(httpurlconnectionimpl.java:206) 02-05 18:52:44.497 5263-6265/com.rm w/system.err: @ com.android.okhttp.internal.http.delegatinghttpsurlconnection.getinputstream(delegatinghttpsurlconnection.java:210) 02-05 18:52:44.497 5263-6265/com.rm w/system.err: @ com.android.okhttp.internal.http.httpsurlconnectionimpl.getinputstream(httpsurlconnectionimpl.java:25) 02-05 18:52:44.497 5263-6265/com.rm w/system.err: @ navigationfragments.fragmentwebview$1.shouldinterceptrequest(fragmentwebview.java:124) 02-05 18:52:44.497 5263-6265/com.rm w/system.err: @ android.webkit.webviewclient.shouldinterceptrequest(webviewclient.java:125) 02-05 18:52:44.498 5263-6265/com.rm w/system.err: @ com.android.webview.chromium.webviewcontentsclientadapter.shouldinterceptrequest(webviewcontentsclientadapter.java:297) 02-05 18:52:44.498 5263-6265/com.rm w/system.err: @ org.chromium.android_webview.awcontents$backgroundthreadclientimpl.shouldinterceptrequest(awcontents.java:465) 02-05 18:52:44.498 5263-6265/com.crm w/system.err: @ org.chromium.android_webview.awcontentsbackgroundthreadclient.shouldinterceptrequestfromnative(awcontentsbackgroundthreadclient.java:38)
but amazement, if click on link:
https://fonts.googleapis.com/css?family=roboto:400,300,500,700,900,700italic
i can load in browser. happens many opther files too, can accessed browser. miss here?
below custom implementation:
webviewclient webviewclient = new webviewclient() { @override public void onpagestarted(webview view, string url, bitmap favicon) { startanim(); super.onpagestarted(view, url, favicon); } @override public void onpagefinished(webview view, string url) { super.onpagefinished(view, url); if (webview.getprogress() == 100) { stopanim(); } } @override public void onreceivederror(webview view, int errorcode, string description, string failingurl) { nonetworkdialog.shownetworkdialog(getactivity()); } @override public boolean shouldoverrideurlloading(webview view, string url) { if (!checkconnection.isnetworkconnected(getactivity())) { nonetworkdialog.shownetworkdialog(getactivity()); return false; } else { view.loadurl(url); return true; } } @override public webresourceresponse shouldinterceptrequest(webview view, string url1) { // if (!checkconnection.isnetworkconnected(getactivity())) { // nonetworkdialog.shownetworkdialog(getactivity()); // } else { try { url url = new url(url1); httpsurlconnection urlconnection = (httpsurlconnection) url.openconnection(); cookiemanager cookiemanager = cookiemanager.getinstance(); string cookie = cookiemanager.getcookie(url.gethost()); urlconnection.setdooutput(true); urlconnection.setrequestproperty("cookie", cookie); urlconnection.setrequestproperty("***_user_agent", "***_app"); urlconnection.setrequestmethod("get"); inputstream in = new bufferedinputstream(urlconnection.getinputstream()); return new webresourceresponse(urlconnection.getcontenttype(), "utf-8", in); } catch (exception e) { e.printstacktrace(); return null; } // } // return null; } };
here other url's on:
https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js
https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js
delete setdooutput()
, see if works. you're not doing post request , not need it.
reference link here.
Comments
Post a Comment