`
rensanning
  • 浏览: 3513571 次
  • 性别: Icon_minigender_1
  • 来自: 大连
博客专栏
Efef1dba-f7dd-3931-8a61-8e1c76c3e39f
使用Titanium Mo...
浏览量:37470
Bbab2146-6e1d-3c50-acd6-c8bae29e307d
Cordova 3.x入门...
浏览量:604277
C08766e7-8a33-3f9b-9155-654af05c3484
常用Java开源Libra...
浏览量:677980
77063fb3-0ee7-3bfa-9c72-2a0234ebf83e
搭建 CentOS 6 服...
浏览量:87228
E40e5e76-1f3b-398e-b6a6-dc9cfbb38156
Spring Boot 入...
浏览量:399796
Abe39461-b089-344f-99fa-cdfbddea0e18
基于Spring Secu...
浏览量:69057
66a41a70-fdf0-3dc9-aa31-19b7e8b24672
MQTT入门
浏览量:90457
社区版块
存档分类
最新评论

Cordova 3.x 实用插件(4) -- Android的SEND、VIEW、CALL(WebIntent)

阅读更多
插件地址:https://github.com/Initsogar/cordova-webintent

(1)创建工程
引用
cordova create HelloWebIntent com.rensanning.cordova HelloWebIntent
cd HelloWebIntent
cordova platform add android


(2)安装plugin
引用
cordova plugin add https://github.com/Initsogar/cordova-webintent.git


(3)修改index.html后编译执行
<a href="#" class="btn" id="send">ACTION_SEND</a>
<a href="#" class="btn" id="view">ACTION_VIEW</a>
<a href="#" class="btn" id="call">ACTION_CALL</a>

<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
  $(document).on('deviceready', function() {
      $('#send').on('click', send);
      $('#view').on('click', view);
      $('#call').on('click', call);
  });

  function send() {
    alert("send");
    var extras = {};
    extras[window.plugins.webintent.EXTRA_EMAIL] = "rensanning@gmail.com";
    extras[window.plugins.webintent.EXTRA_SUBJECT] = "Subject";
    extras[window.plugins.webintent.EXTRA_TEXT] = "Text text";
    //extras[WebIntent.EXTRA_STREAM] = "file:///android_asset/www/index.html";
    window.plugins.webintent.startActivity({
      action: window.plugins.webintent.ACTION_SEND,
      type: 'text/plain',
      extras: extras},
      function() {},
      function() {alert('Failed to send email via Android Intent');}
    );
  }

  function view() {
    alert("view");
    window.plugins.webintent.startActivity({
      action: window.plugins.webintent.ACTION_VIEW,
      url: 'http://www.baidu.com'},
      function() {},
      function() {alert('Failed to open URL via Android Intent');}
    );
  }

  function call() {
    alert("call");
    window.plugins.webintent.startActivity({
      action: window.plugins.webintent.ACTION_CALL,
      url: 'tel:10086'},
      function() {},
      function() {alert('Failed to Call TEL via Android Intent');}
    );
  }
</script>




 



  • 大小: 14.5 KB
  • 大小: 71.9 KB
  • 大小: 100 KB
  • 大小: 40.4 KB
  • 大小: 30.8 KB
分享到:
评论
1 楼 woyanjyihei 2014-04-25  
点击没反应啊。。。貌似调用不成功,第一个alert信息有,后面没动静了,这是什么原因啊。?谢谢

相关推荐

Global site tag (gtag.js) - Google Analytics