Android WebView: handling orientation changes

glennanthonyb picture glennanthonyb · Jun 16, 2009 · Viewed 95.8k times · Source

The issue is the performance following rotation. The WebView has to reload the page, which can be a bit tedious.

What's the best way of handling an orientation change without reloading the page from source each time?

Answer

Totach picture Totach · Feb 11, 2010

If you do not want the WebView to reload on orientation changes simply override onConfigurationChanged in your Activity class:

@Override
public void onConfigurationChanged(Configuration newConfig){        
    super.onConfigurationChanged(newConfig);
}

And set the android:configChanges attribute in the manifest:

<activity android:name="..."
          android:label="@string/appName"
          android:configChanges="orientation|screenSize"

for more info see:
http://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange

https://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges