title: Android WebView new window null URLs on relative links
body: <p>I have implemented a custom <code>WebView</code> with <code>setSupportMultipleWindows()</code> enabled. As such, I also have a custom <code>WebChromeClient</code> that overrides <code>onCreateWindow()</code></p>
  
  <p>For most uses, I was using the following snippet to retrieve the URL for a page in a new window (i.e. opened via <code>target:_blank</code>):</p>
  
  <pre><code>Message href = view.getHandler().obtainMessage();
  view.requestFocusNodeHref(href);
  
  String url = href.getData().getString("url");
  </code></pre>
  
  <p>There's null checks in place but I've removed them in the snippet above for simplicity's sake. Now the issue is that sometimes the data <code>Bundle</code> (returned via <code>getData()</code>) has a null URL for relative links (i.e. <code>href="/somepage"</code> instead of <code>href="https://www.example.com/somepage/"</code>).</p>
  
  <p>So I searched on SO and found another possible solution:</p>
  
  <pre><code>WebView.HitTestResult result = view.getHitTestResult();
  String url = result.getExtra();
  </code></pre>
  
  <p>However, that also returns null. If I get the type of the data using <code>result.getType()</code> it returns 0, which maps to <code>UNKNOWN_TYPE</code>.`</p>
  
  <p>I am unsure why it is returning null for the aforementioned methods.
  N.B. that if I disable support of multiple windows, those same links work just fine. Disabling such support, however, is not an option. <strong>Is there another way to get the URL from within <code>onCreateWindow()</code>?</strong></p>