Android WebView err_unknown_url_scheme

后端 未结 5 700
花落未央
花落未央 2020-11-27 05:11

With the simple below code I can get my url loaded correctly, but, I get \"ERR_UNKNOWN_URL_SCHEME\" when trying to tap on html links that starts with mailto: wh

5条回答
  •  独厮守ぢ
    2020-11-27 05:58

    mailto links will not get loaded in your webview.You have check for it like this in shouldOverrideUrlLoading and handle it with intent.

        public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.startsWith("mailto:")) {
    
            Intent share = new Intent(Intent.ACTION_SEND);
            share.setType("text/plain");
            share.putExtra(Intent.EXTRA_TEXT, message);
            startActivity(Intent.createChooser(share, "Title of the dialog the system will open"));
            view.reload();
            return true;
        }
      }
    

    Similar question Android Webview ERR_UNKNOWN_URL_SCHEME Error

提交回复
热议问题