Support for other protocols in Android webview

前端 未结 7 2115
囚心锁ツ
囚心锁ツ 2020-11-29 04:08

I\'ve created a web view app, the page that is displayed features market:// links but upon clicking them I get the 404 screen along with the error that the protocol is not s

相关标签:
7条回答
  • 2020-11-29 04:54

    HOPE THIS HELPS YOU

    public boolean shouldOverrideUrlLoading(WebView view, String url) 
    {
        if (url.startsWith("market://")||url.startsWith("vnd:youtube")||url.startsWith("tel:")||url.startsWith("mailto:"))
        {
            Intent intent = new Intent(Intent.ACTION_VIEW); 
            intent.setData(Uri.parse(url)); 
            startActivity(intent);
            return true;
         }
        else{
            view.loadUrl(url);
            return true;
            }
    }
    
    0 讨论(0)
提交回复
热议问题