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);
            }

        } 

  • 相关阅读:
    ubuntu播放器
    第一次装ubuntu 没root密码时
    web服务器记录
    socket udp编程步骤
    nfs服务器配置
    带线程函数编译条件
    linux使用一个刚编译驱动方法
    tiny6410_led驱动Makefile
    java-设计模式-外观模式
    java-实现一个简单的java Web容器
  • 原文地址:https://www.cnblogs.com/yourancao520/p/2313148.html
Copyright © 2011-2022 走看看