Note that there are some explanatory texts on larger screens.

plurals
  1. POWebView's restorePicture method - Preventing webview to reload the page
    text
    copied!<p>As I say in the topic, I want my WebView to prevent from reloading the webpage when another activity comes to the foreground or just when the orientation is changed. The reason why is because the WebView content is generated by Javascript/AJAX almost completely. After searching on a couple of forums, I found out many people suggested to use "saveState" and "restoreState" methods, but when I look the documentation, it says:</p> <blockquote> <p>Please note that this method no longer restores the display data for this WebView. See savePicture(Bundle, File) and restorePicture(Bundle, File) for saving and restoring the display data.</p> </blockquote> <p>So, here I was using that savePicture and restorePicture as it follows:</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); </code></pre> <p>... some other lines ....</p> <pre><code> setContentView(R.layout.main); mWebView = (WebView) findViewById(R.id.webview); if (savedInstanceState == null){ loadInicialWebUi(); }else{ mWebView.restoreState(savedInstanceState); boolean restoredPic = mWebView.restorePicture(savedInstanceState, new File("savedDisplayWebView.temp")); Log.d(TAG, "restored Picture:" + restoredPic); } } @Override protected void onSaveInstanceState(Bundle savedInstanceState) { mWebView.saveState(savedInstanceState); boolean savedPic = mWebView.savePicture(savedInstanceState, "savedDisplayWebView.temp"); Log.d(TAG, "saved Picture:" + savedPic); super.onSaveInstanceState(savedInstanceState); } </code></pre> <p>And well, those logs were revealing that it saves the picture, but it couldn't restore it. I suspect there might be something about the File references, but I couldn't think of a better way of getting the reference of the File I created when saving the state.</p> <p>Anyone thrilled? I would appreciate any clues/suggestions. Thanks in advance.</p> <p>Manuel.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload