android - webview not cacheing on galaxy grand 2 -
actually i'm making program needs cache website page , if there no connection, should open cached page offline , works fine on galaxy s4, on galaxy grand 2 page not loaded , instead loads default error page here code , in advance help.
protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.exchange_app); b= (button)findviewbyid(r.id.button1); tv = (edittext)findviewbyid(r.id.edittext2); webview=(webview) findviewbyid(r.id.webview1); imageview= (imageview)findviewbyid(r.id.imageview1); webview.getsettings().setjavascriptenabled(true); webview.setwebchromeclient(new webchromeclient() { @override public void onreachedmaxappcachesize(long spaceneeded, long totalusedquota, webstorage.quotaupdater quotaupdater) { quotaupdater.updatequota(spaceneeded * 2); } }); webview.getsettings().setdomstorageenabled(true); // webview.getsettings().setallowfileaccessfromfileurls(true); // webview.getsettings().setallowuniversalaccessfromfileurls(true); // webview.getsettings().load_cache_else_network // set cache size 8 mb default. should more enough webview.getsettings().setappcachemaxsize(1024*1024*8); // next 1 crazy. it's default location app's cache // didn't work me without line. // update: no hardcoded path. kevin hawkins string appcachepath = getapplicationcontext().getcachedir().getabsolutepath(); webview.getsettings().setappcachepath(appcachepath); webview.getsettings().setallowfileaccess(true); webview.getsettings().setappcacheenabled(true); webview.getsettings().setcachemode(websettings.load_default); webview.loadurl("http://www.syria-stocks.us/dollarrange/test3.php"); //readwebpage(tv); webview.setwebviewclient(new webviewclient() { @override public void onpagefinished(webview view, string url) { webview.setvisibility(webview.visible); super.onpagefinished(view, url); } @override public void onreceivederror(webview view, int errorcode, string description, string failingurl) { // todo auto-generated method stub webview.setvisibility(webview.invisible); super.onreceivederror(view, errorcode, description, failingurl); if (webview.getsettings().getcachemode()!=websettings.load_cache_only){ webview.getsettings().setcachemode( websettings.load_cache_only ); webview.loadurl("http://www.syria-stocks.us/dollarrange/test3.php"); toast.maketext(getapplicationcontext(), "no connection", toast.length_short).show(); } } });
catlog:
05-17 21:37:51.594: d/webview(29190): onsizechanged - w:720 h:556 05-17 21:37:53.934: v/webviewinputdispatcher(29190): blockwebkitdraw 05-17 21:37:53.934: v/webviewinputdispatcher(29190): blockwebkitdraw lockedfalse 05-17 21:37:54.234: d/webview(29190): blockwebkitviewmessage= false 05-17 21:37:54.704: v/webviewinputdispatcher(29190): blockwebkitdraw 05-17 21:37:54.704: v/webviewinputdispatcher(29190): blockwebkitdraw lockedfalse 05-17 21:37:55.004: d/webview(29190): blockwebkitviewmessage= false 05-17 21:38:05.414: i/webclipboard(29190): clipservice: android.sec.clipboard.clipboardexmanager@426b2cf0 05-17 21:38:05.414: v/webkit(29190): browserframe constructor: this=handler (android.webkit.browserframe) {426b9528} 05-17 21:38:05.424: d/webview(29190): loadurlimpl: called 05-17 21:38:05.424: d/webcore(29190): core loadurl: called 05-17 21:38:05.424: d/webkit(29190): firewall not null 05-17 21:38:05.424: d/webkit(29190): euler: isurlblocked = false 05-17 21:38:05.424: i/gate(29190): <gate-m>dev_action_error</gate-m> 05-17 21:38:05.434: v/webkit(29190): reporterror errorcode(-2) desc(couldn't find url.)
Comments
Post a Comment