title: WebView: How to find the base URL of the current page?
body: <p>WebView has <a href="http://developer.android.com/reference/android/webkit/WebView.html#getUrl%28%29" rel="nofollow noreferrer">getUrl()</a> and it has <a href="http://developer.android.com/reference/android/webkit/WebView.html#loadDataWithBaseURL%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String%29" rel="nofollow noreferrer">loadDataWithBaseUrl()</a> but I can't find a method that returns the base URL (note: "base URL" is <a href="https://stackoverflow.com/questions/4492944/extract-base-url-from-full-url/4493009#comment-8561124">not</a> the same as server/host path).</p>
  
  <p>Is there a way to find the base URL of the current web page, even for pages that don't use the <a href="http://www.w3schools.com/tags/tag_base.asp" rel="nofollow noreferrer"></a> tag, but do use relative URLs in links contained in the page?</p>
  
  <p>Note the complexity of the problem:</p>
  
  <ul>
  <li><a href="http://developer.android.com/reference/android/webkit/WebView.html#getUrl%28%29" rel="nofollow noreferrer">getUrl()</a> isn't always the base URL.</li>
  <li><a href="https://stackoverflow.com/questions/4492944/extract-base-url-from-full-url/4493009#4493009">Server/host path</a> isn't always the base URL.</li>
  <li>Web pages don't always contain the <a href="http://www.w3schools.com/tags/tag_base.asp" rel="nofollow noreferrer"><code>&lt;base&gt;</code></a> tag.</li>
  </ul>
  
  <p>This may explain why there isn't a single <code>WebView</code> method to provide the base URL...</p>