Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 当URL为“时,如何避免畸形异常”;数据:text/html“;?_Android_Url_Webview_Malformedurlexception - Fatal编程技术网

Android 当URL为“时,如何避免畸形异常”;数据:text/html“;?

Android 当URL为“时,如何避免畸形异常”;数据:text/html“;?,android,url,webview,malformedurlexception,Android,Url,Webview,Malformedurlexception,在我的基于WebView的应用程序中,当应用程序访问我的WebViewClient时,会收到6-7 onPageFinished(),第一个3-4,返回原始URL(),但其余返回“data:text/html” 显然,这是一个很好的例子。另见 但是,在我的代码中,我需要从WebView的URL实例化一个URL,如下所示: new URL(myWebView.getUrl()); 不幸的是,当WebView.getUrl()返回“data:text/html”时,这会引发一个错误的FormedU

在我的基于WebView的应用程序中,当应用程序访问我的WebViewClient时,会收到6-7 onPageFinished(),第一个3-4,返回原始URL(),但其余返回“data:text/html”

显然,这是一个很好的例子。另见

但是,在我的代码中,我需要从WebView的URL实例化一个URL,如下所示:

new URL(myWebView.getUrl());
不幸的是,当WebView.getUrl()返回“data:text/html”时,这会引发一个错误的FormedUrlexception


是否有方法将“data:text/html”字符串转换为有效的URL字符串,以便
new URL()
不会在写入数据时引发畸形异常

有效的URI不是URL

编写数据时:是有效的URI而不是URL

那怎么办?另外,如果它不是一个有效的URL,为什么
WebView.getUrl()
会返回它呢?另外,如果它不是有效的URL,为什么
WebView.getUrl()
会返回它?