title: Http Response in Webview Android
body: <p>I have my activity that loads webview as below </p>
  
  <pre><code> @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      // set layout
      setContentView(R.layout.activity_webview);
      // get loading view
      loadingView = findViewById(R.id.loadingView);
      loadingView.setVisibility(View.VISIBLE);
      // extract extras from intent
      Intent intent = getIntent();
  
      // get and setup WebView
      webview = (WebView) findViewById(R.id.webView);
      // implement progress bar
      webview.setWebViewClient(new WebViewClient() {
  
          public void onPageFinished(WebView view, String url) {
              loadingView.setVisibility(View.GONE);
              // if no title was passed in with the intent use the page's title
              if (TextUtils.isEmpty(title)) {
                  getSupportActionBar().setDisplayShowTitleEnabled(true);
                  getSupportActionBar().setTitle(view.getTitle());
              }
          }
  
          @SuppressWarnings("deprecation")
          public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
              showErrorAndFinish();
          }
  
          @TargetApi(Build.VERSION_CODES.M)
          @Override
          public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
              // Redirect to deprecated method, so you can use it in all SDK versions
              onReceivedError(view, error.getErrorCode(), error.getDescription().toString(), request.getUrl().toString());
          }
  
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
              return super.shouldOverrideUrlLoading(view, url);
          }
  
          @Override
          public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
              return super.shouldInterceptRequest(view, request);
          }
      });
      // load the url
      webView.loadUrl(url);
  }
  </code></pre>
  
  <p>However, I need to look at response of the Url that I load and call to another API URL based on the response.</p>
  
  <p>I have looked so far for this<a href="https://stackoverflow.com/questions/3134389/access-the-http-response-headers-in-a-webview?lq=1">URL Loading QUestion</a> but not much helpful under 5.0. Any suggestions on how should I approach? Should I just use Retrofit in <code>shouldOverrideUrlLoading()</code> method? </p>
  
  <p>Also, I cannot modify both the URL's that I am loading .</p>
  
  <p>I would appreciate the response</p>