2014-10-31 56 views
2

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

我使用netbeans 8.0.1创建了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:[email protected]?subject=Hello" >Send Mail</a></h1> 
     <script type="text/javascript" src="cordova.js"></script> 
    </body> 
</html> 

奇怪的是,我在上次尝试,安装科尔多瓦的所有核心插件,但它仍然没有奏效。

请帮我...谢谢...

编辑:我refered这些链接,但它没有帮助:

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/

回答

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:[email protected]?subject=Hello", "_system"); // or if _system doesnt work 
       window.open("mailto:[email protected]?subject=Hello", "_blank"); 
      } 
     </script> 
    </body> 
</html> 

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

+1

谢谢你.. 它工作得很好,因为我期望。 – Hims 2014-11-03 12:50:59

+0

总是欢迎您,亲爱的.. – 2014-11-03 12:51:21

3

对于电话:

这工作对我来说唯一的解决办法是:

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

我试图在Android其工作。 Cordova -v 4.1.2

+0

感谢您提供简单可靠的解决方案。 – SalmanShariati 2015-03-04 15:07:56

相关问题