android - WebView prevent reloading in RetainInstance fragment -


I'm having a problem preventing a webview from reloading, as well as keeping it inside a piece Really set the set

The paths I have tried:

SaveInstanceState (does not pass on rotation due to maintaining a bundle) a custom bundle that is saved on onSaveInstanceState and In maintaining the webview context, it is restored and attempts to add it back

You can do this very easily because you already maintain this example, in this detachment you can see the WebView Do Drb the place and said it (Ondestoryuwu the fragment) to separate it from parents. If it is non-blank, then simply return it to the curvature () for example:

  the public class enhances the webfiguration slice {Private webview mWebView; @ Override Public ViewCreative (LayoutEfter Inflator, View Group Container, Bundle Saved InstantState) {if (mWebView == empty) {mWebView = New WebView (getActivity ()); } Return mWebView; } @ Override Public Empty OnDestoy View () {super.onDestroyView (); If getRetainInstance () & amp; amp; amp; amp; amp; amp; amp;; & amp;; MWebView.getParent) example ViewGroup {(ViewGroup) mWebView.getParent ()). RemoveView (mWebView); However, you will first leak a reference for the first activity on Orientation changes - I have not yet figured out how to avoid that. There is no way to set the context on a view for my knowledge, it works, though, if you are ok with that one memory leak. Edit: Alternatively, if you are translating it into this program because I am doing this example, then you just use  getActivity (). GetApplicationContext ()  to avoid leaking activity. If you use the provided layout infrator, this will reference the application for viewers while increasing. 

Do not use the application context for a WebView - it's showing a drop-down view and possibly due to other problems causing unexpected crashes.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -