Cordova + android : not able to open dial pad or m

2020-07-27 05:22发布

I have a strange problem. I am not able to open either dial pad with pre defined number or mail intent from app.

I am using netbeans 8.0.1 for creating cordova apps. My Cordova version is 4.0.0.

I created an app following the steps and selected a template of HelloWorld Cordova. I modified its html file to something as below:

<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>

Strange thing is that, I at last tried, installing all the core plugins of Cordova, but still it didn't work.

Please help me out... Thanks...

Edit: I refered these links, but it didnt help:

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条回答
对你真心纯属浪费
2楼-- · 2020-07-27 05:34

Yes.. I too was trapped with this error for 3 days... and after that I found a solution. I dont remember the URL from which i found it, but I remember the solution.

First of all, You need to install In-App browser plugin of Cordova into your app.

and then, with just a little modification to your html you will get what you want.

<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>

Hope you get what you want. The above was just an example. You can modify it as per your requirements.

查看更多
Lonely孤独者°
3楼-- · 2020-07-27 05:48

For Call:

The only solution which worked for me is:

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

I tried on android its working. Cordova -v 4.1.2

查看更多
登录 后发表回答