1
好吧,我的WebView的內容中將有兩種類型的鏈接。行爲將由鏈接的格式定義。創建意圖點擊WebView鏈接
(1) Open the link in a browser. (The url begins with "openbrowser:")
(2) According to the link, open another Activity in the same project.
(The url will be "openactivity")
我不確定是否有可能爲WebView創建映射從url模式到意圖的映射。例如,默認情況下,如果網址以「mailto:」開頭,則WebView將創建打開郵箱的意圖。我可以爲我的WebView定義其他映射嗎?
我知道有一種方法來設置WebViewClient並覆蓋shouldOverrideUrlLoading()方法。但是,在API級別19,功能不能保證被稱爲:
shouldOverrideUrlLoading() not called
所以是有可能這個網址模式的意圖映射設置爲WebView中的一般設置?
我正在使用Kit Kat設備使用此方法(自定義模式),並且沒有遇到任何問題。你測試過了嗎? – matiash
在我的情況下,要在WebView中顯示的數據作爲HTML字符串從服務器返回。因此,我將使用contentWebView.loadData(htmlString,「text/html」,「utf-8」)加載數據。我不確定這是否是你的情況。 – darklord
這就是我們的情況。請參閱答案中的示例。 :) – matiash