首页 文章

Cordova android:无法从应用程序打开拨号盘或邮件意图

提问于
浏览
2

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

我正在使用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的所有核心插件,但它仍然没有用 .

请帮帮我...谢谢......

Edit: 我提到了这些链接,但它没有帮助:

Call predefined number automatically on Android with PhoneGap

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

2 回答

  • 1

    是的..我也被这个错误困住了3天......之后我找到了一个解决方案 . 我不记得我发现它的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>
    

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

  • 3

    致电:

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

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

    我尝试了android的工作 . Cordova -v 4.1.2

相关问题