android - Save state of webpage in webview inside fragment -
using navigation drawer calling webpage inside webview. when moving through menu reloading whole website , again , again. want save state of webpage user left not start of webpage.
thanks help.
code:-
public class facebook extends fragment { // fragment called mainactivity public facebook(){} private webview webview ; private bundle webviewbundle; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.facebook, container, false); webview = (webview) rootview.findviewbyid(r.id.facebook); webview.setwebviewclient(new webviewclient()); webview.getsettings().setloadwithoverviewmode(true); webview.setscrollbarstyle(view.scrollbars_inside_overlay); webview.getsettings().setjavascriptenabled(true); webview.getsettings().setbuiltinzoomcontrols(true); webview.getsettings().setsupportzoom(true); webview.getsettings().setjavascriptcanopenwindowsautomatically(true); webview.getsettings().setallowfileaccess(true); webview.getsettings().setdomstorageenabled(true); webview.getsettings().setrenderpriority(renderpriority.high); if (webviewbundle == null) { try{ webview.loadurl("http://www.facebook.com"); }catch (exception e){ e.printstacktrace();} } else { webview.restorestate(webviewbundle); } return rootview; } public boolean shouldoverrideurlloading(webview view, string url) { view.loadurl(url); return true; } public void onpause() { super.onpause(); webviewbundle = new bundle(); webview.savestate(webviewbundle); } }
have tried setting cache mode load_cache_only after loaded website first time?
websettings websettings = webview.getsettings(); websettings.setcachemode(load_cache_only);
Comments
Post a Comment