Skip to content Skip to sidebar Skip to footer

Android Webview (4.4) Converts Custom Url

I have an app that heavily uses the Android WebView to display my custom HTML content. The latest Android update (4.4/Kit-Kat/SDK-19) featured a redesigned WebView. One of my user

Solution 1:

Changes in URL handling are a known issue. Please see the migration guide for more detail.

The behaviour in this particular case will depend on what your base URL's scheme is, from what you're describing I'm guessing your base URL's scheme is "http(s)://" in which case the Chromium WebView performs URL normalization.

You might want to consider using the URI class to handle the discrepancy between the Classic and Chromium WebViews in this case.

Solution 2:

I did more debugging and discovered I actually have the question reversed. Turns out the older versions of WebView did conversions of the URL, not the new one.

I load HTML with a format similar to this into a WebView:

<a href="this\\is\\my\\custom\\path">link</a>

I use the double back slashes as delimiters and parse the data later when the link is clicked. In older versions of WebView it converted my double backslash characters into forward slashes. It had been so long since I was in that code, I forgot I adjusted my code to use forward slashes rather than the backslashes in the original HTML.

The new version of WebView leaves my custom URL intact, giving me the exact same string as my original HTML. So turns out the old WebView is the problem not the new one.

Solution 3:

to avoid webview below 4.4 convert backslash to forward slash, I just escape my url, then in Java code, use URI.decode to get the real url.That works for me.

Post a Comment for "Android Webview (4.4) Converts Custom Url"