title: Forwarding to other www if url returns error. How to write this?
body: <p>I need an android WebView app which forwards to "second" url if first url returns error: <strong>(ERR_NAME_NOT_RESOLVED)</strong>.</p>
  
  <p>Below I pasted java code. It works fine for one url but I need sth like an if statement.
  I tried to do this by <code>onReceivedError</code> method but I can't do this.</p>
  
  <p>I'm new in Android development so I need your help ;)</p>
  
  <p>Java code:</p>
  
  <pre><code>package com.example.webview;
  
  import android.content.DialogInterface;
  import android.support.v7.app.AlertDialog;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  
  import java.net.URL;
  
  public class MainActivity extends AppCompatActivity {
  private WebView webView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      WebView webView = (WebView) findViewById(R.id.webview);
  
  
      webView.setWebViewClient(new WebViewClient());
      webView.loadUrl("http://google.com");
  
      }
  
  }
  
  </code></pre>