2016-06-24 32 views
0

舊的問題的新的轉折。如何使用「Referer」/ Referrer將html加載到webview中,並從資源或可繪製目錄加載文件。帶查閱者和資產的Webview.loadDataWithBaseURL

加載「Referer」或「Referrer」。

webview.loadDataWithBaseURL("www.refererurl.com", html, "text/html", "utf-8", null); 

使用www.refererurl.com將阻止資源被加載。

webview.loadDataWithBaseURL(null, html, "text/html", "utf-8", null); 

使用null作爲第一個參數將資產裝入如果HTML包含類似:

file:///android_asset/ic_launcher.png 

那麼,如何做到既,負荷資產和負載從一個引薦?

+0

對於一個完全合格的URL('文件:/// ...')在HTML中,'baseURL'(第一個參數'loadDataWithBaseURL( )')應該沒關係。 – CommonsWare

+0

我同意它不應該但是從我所有的測試中,如果我把'file:/// ...'放入html資源永遠不會加載。測試了幾種方法來確保路徑有效,但仍無法加載。 *使用引用URL * @CommonsWare加載時 – Matthew

回答

0

如果我正確地閱讀文檔看起來像不能加載引用程序並加載資源。

從上loadDataWithBaseURL web視圖文檔:

* Note that content specified in this way can access local device files 
* (via 'file' scheme URLs) only if baseUrl specifies a scheme other than 
* 'http', 'https', 'ftp', 'ftps', 'about' or 'javascript'.