相关疑难解决方法(0)

MailTo 在 Android WebView 中不起作用

我正在研究一个网站的 Android Webview。我有包括mailto联系和电子邮件给朋友。网页端的代码片段:

联系方式: <a href="mailto:contact@example.com">contact@example.com</a>

给朋友的电子邮件: <a href="mailto:?subject=Check out this product&amp;body=I found this awesome product%20http://www.example.com/product-detail/61/" title="Email to a Friend" class=""><span>Email to a Friend</span></a>

我在shouldOverrideUrlLoading方法中包含以下 Android 端的代码片段:

@Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if( url.startsWith("http:") || url.startsWith("https:") ) {
            return false;
        }

        else if (url.startsWith("tel:")) {
            Intent tel = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
            startActivity(tel);
            return true;
        }
        else if(url.startsWith("mailto:")) {
            MailTo mailTo = MailTo.parse(url);
            String emailAddress = mailTo.getTo();
            String subject = mailTo.getSubject();
            String body = …
Run Code Online (Sandbox Code Playgroud)

android webview

2
推荐指数
1
解决办法
4373
查看次数

标签 统计

android ×1

webview ×1