zoukankan      html  css  js  c++  java
  • android中在html页中调用拨号盘

    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    </head>
    <body>
    <input type="button" value="hello" onclick="window.demo.clickOnAndroid()"></input>
    <input type="button" value="call 400" onclick="window.demo.call('400-851-7517')"></input>
    <a href="javascript:demo.call('400-851-7517')">400-851-7517</a>
    </body>
    </html>

     后用代码:

    webview.addJavascriptInterface(new DemoJavaScriptInterface(), "demo"); 

    final class DemoJavaScriptInterface {
            DemoJavaScriptInterface() {
            }
            /**
             * This is not called on the UI thread. Post a runnable to invoke
             * loadUrl on the UI thread.
             */
            public void clickOnAndroid() {
                mHandler.post(new Runnable() {
                    public void run() {
                    Log.i("1111111111111111", "111111111111111111");
                    if (webview.canGoBack()) {
                webview.goBack();
                return;
                }
                   
                    }
                });
            }
            
            public void call(String mobile){
            Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("tel://" + mobile));//没有直接拨出号码
            //Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel://" + mobile));//直接拨出号码
            startActivity(intent);
            }

        } 

  • 相关阅读:
    JMeter
    MeasureSpec介绍及使用详解
    AS中一些不经常用到的快捷键
    gradle 构建工具,与Ant Maven关系
    关于runOnUiThread()与Handler两种更新UI的方法
    关于new Handler()与new Handler(Looper.getMainLooper())区别
    RTSP协议详解
    overridePendingTransition的简介
    Android获取手机分辨率DisplayMetircs类
    RTSP消息交互过程
  • 原文地址:https://www.cnblogs.com/yourancao520/p/2313148.html
Copyright © 2011-2022 走看看