Changing fragments and saving web view states - going mad
<p>Ive been trying to do this for the best part of a week and still have no luck.</p>

<p>I have an action bar with tabs (action bar sherlock) and Im switching through the tabs and changing fragments fine.</p>

<p>Each fragment has a webview and Im trying to save the state of the webview so the web page stays on the same page that the user left it on.</p>

<p>Here is my fragment code:</p>

<pre><code>public class FragmentB extends SherlockFragment {

WebView myWebView;

@Override
public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   myWebView.saveState(outState);
   Log.w("///////", "onSaveInstanceState");

}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   myWebView.restoreState(savedInstanceState);
   Log.w("///////", "onActivityCreated");

}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.w("///////", "onCreate");
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

     View mainView = (View) inflater.inflate(R.layout.frag_b, container, false);
     myWebView = (WebView) mainView.findViewById(R.id.webview);


     Log.w("///////", "onCreateView");


     if (savedInstanceState != null){

         myWebView.restoreState(savedInstanceState);
         Log.w("///////", "restore!");
     }
     else{
         Log.w("///////", "ELSE!");
         myWebView.setWebViewClient(new MyWebViewClient());
         myWebView.getSettings().setPluginsEnabled(true);
         myWebView.getSettings().setBuiltInZoomControls(false); 
         myWebView.getSettings().setSupportZoom(false);
         myWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);   
         myWebView.getSettings().setAllowFileAccess(true); 
         myWebView.getSettings().setDomStorageEnabled(true);
         myWebView.loadUrl("http://www.google.com");   
     }



    //return inflater.inflate(R.layout.frag_b, container, false);
    return mainView;
}

public class MyWebViewClient extends WebViewClient {        

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.endsWith(".mp4")) 
        {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse(url), "video/*");

            view.getContext().startActivity(intent);
            return true;
        } 
        else {
            return super.shouldOverrideUrlLoading(view, url);
        }
    }

}
</code></pre>

<p>}</p>

<p>Any help would be great!</p>
