title: Android WebView refresh on orientation change
body: <p>I have an app that uses webview to load a URL. It has a login function. After logging in, it will redirect to a main page. My codes are as below.</p>
  
  <pre><code>    @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      myWebView = (WebView) findViewById(R.id.webview);
      WebSettings webSettings = myWebView.getSettings();
      webSettings.setJavaScriptEnabled(true);
      webSettings.setDomStorageEnabled(true);
  
      myWebView.setWebViewClient(new WebViewClient());
      myWebView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
  
      if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE)
          != PackageManager.PERMISSION_GRANTED) {
  
          ActivityCompat.requestPermissions(this,
              new String[]{Manifest.permission.READ_PHONE_STATE},
              MY_PERMISSIONS_REQUEST_READ_PHONE_STATE);
      } else {
          loadURL();
      }
  }
  
  @Override
  public void onRequestPermissionsResult(int requestCode,
                                         String permissions[], int[] grantResults) {
      switch (requestCode) {
          case MY_PERMISSIONS_REQUEST_READ_PHONE_STATE: {
              if (grantResults.length &gt; 0
                      &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                  loadURL();
              } else {
                  ActivityCompat.requestPermissions(this,
                          new String[]{Manifest.permission.READ_PHONE_STATE},
                          MY_PERMISSIONS_REQUEST_READ_PHONE_STATE);
              }
              return;
          }
      }
  }
  
  private void loadURL() {
      //myWebView.loadUrl("http://192.168.0.198:8080/dashboard/");
  
      myWebView.loadUrl("http://192.168.0.156:8080/dashboard/");
  }
  </code></pre>
  
  <p>And below is my AndroidManifest.xml file.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.tg_david.myapplication"&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:configChanges="orientation|screenSize"
      android:theme="@style/AppTheme"&gt;
      &lt;activity android:name=".MainActivity"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>As you can see, I have included <code>android:configChanges="orientation|screenSize"</code>, but it still doesn't work. The WebView still refreshes every time the phone changes the orientation. When it refreshes, the page will be redirected back to login page. Could it be because the WebView clear the session when the phone orientation changes and forced the page to logout?</p>