插件地址:
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
分享到:
相关推荐
NULL 博文链接:https://rensanning.iteye.com/blog/2072034
NULL 博文链接:https://rensanning.iteye.com/blog/2034061
实实在在经过ant编译的cordova-2.9.1.jar 而不是有些人坑蒙拐骗的rar文件
NULL 博文链接:https://rensanning.iteye.com/blog/2032663
NULL 博文链接:https://rensanning.iteye.com/blog/2034026
安卓v4支持库cordova-plugin-android-support-v4-jar-master.zip
cordova扫码插件phonegap-plugin-barcodescanner,修复了在ios10上面的内存泄漏导致的闪退bug
NULL 博文链接:https://rensanning.iteye.com/blog/2023480
cordova plugin add cordova-plugin-baidumaplocation --variable ANDROID_KEY="" --variable IOS_KEY="" //此处的API_KEY_XX来自于第一步,直接替换,也可以最后跟 --save 参数,将插件信息保存到config....
cordova-plugin-app-update App updater for Cordova/PhoneGap Demo Try it yourself: Just clone and install this demo. cordova-plugin-app-update-DEMO :tada: 如果喜欢它,请别忘了给我一颗鼓励的星 Support ...
热更新时,我们执行命令 npm install -g cordova-hot-code-push-cli安装插件,但运行cordova-hcp server会报错,如:Could not create tunnel: { Error: ngrok is not yet ready to start tunnels...,这时我们找到...
cordova-android保存图片插件,不知道为何不适用ios,仅供参考
记录了我安全完成cordova工具后,用它生成apk的过程记录
Cordova 3.x(aka PhoneGap)的基础知识、实用插件、源码分析、实例开发。