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

    } 

posted @ 2012-01-05 14:55  扬帆一号86  阅读(2841)  评论(0编辑  收藏  举报