Can I make a phone call from HTML on Android?

后端 未结 3 1792
感动是毒
感动是毒 2020-11-27 12:30

To make a phone call via HTML on an iPhone I create an tag with an href formatted as: Dial Me

3条回答
  •  清歌不尽
    2020-11-27 13:17

    I have just written an app which can make a call from a web page - I don't know if this is any use to you, but I include anyway:

    in your onCreate you'll need to use a webview and assign a WebViewClient, as below:

    browser = (WebView) findViewById(R.id.webkit);
    browser.setWebViewClient(new InternalWebViewClient());
    

    then handle the click on a phone number like this:

    private class InternalWebViewClient extends WebViewClient {
    
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
             if (url.indexOf("tel:") > -1) {
                startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
                return true;
            } else {
                return false;
            }
        }
    }
    

    Let me know if you need more pointers.

提交回复
热议问题