Cordova+安卓:无法从应用程序打开拨号盘或邮件意向



我有一个奇怪的问题。我无法从应用程序打开具有预定义号码或邮件意向的拨号盘。

我使用netbeans 8.0.1创建cordova应用程序。我的Cordova版本是4.0.0。

我按照步骤创建了一个应用程序,并选择了HelloWorld Cordova的模板。我修改了它的html文件如下:

<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="msapplication-tap-highlight" content="no" />
         <!--WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323--> 
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title>Hello World</title>
    </head>
    <body>
        <h1><a href="tel:+919685968574" >call</a></h1><br>
        <h1><a href="mailto:abc@gmail.com?subject=Hello" >Send Mail</a></h1>
        <script type="text/javascript" src="cordova.js"></script>
    </body>
</html>

奇怪的是,我终于试着安装了Cordova的所有核心插件,但仍然没有成功。

请帮帮我。。。谢谢

编辑:我参考了这些链接,但没有帮助:

使用PhoneGap 在Android上自动拨打预定义的号码

http://rickluna.com/wp/2012/02/making-a-phone-call-from-within-phonegap-in-android-and-ios/

呼叫:

唯一对我有效的解决方案是:

navigator.app.loadUrl('tel:+919999999999', { openExternal:true });

我在安卓上试过它的工作。Cordova-v 4.1.2

是。。我也被这个错误困住了三天。。。之后我找到了解决方案。我不记得我找到它的URL,但我记得解决方案。

首先,你需要在你的应用程序中安装Cordova的应用内浏览器插件。

然后,只要对html做一点修改,你就会得到你想要的。

<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="msapplication-tap-highlight" content="no" />
         <!--WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323--> 
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title>Hello World</title>
    </head>
    <body>
        <h1><a href="#" onclick='call()'>call</a></h1><br>
        <h1><a href="#" onclick='email()'>Send Mail</a></h1>
        <script type="text/javascript" src="cordova.js"></script>
        <script>
            function call(){
                window.open("tel:+919685968574", "_system"); // or if _system doesnt work
                window.open("tel:+919685968574", "_blank");
            }
            function email(){
                window.open("mailto:abc@gmail.com?subject=Hello", "_system"); // or if _system doesnt work
                window.open("mailto:abc@gmail.com?subject=Hello", "_blank");
            }
        </script>
    </body>
</html>

希望你得到你想要的。以上只是一个例子。您可以根据自己的要求进行修改。

最新更新