安卓机物理返回键监听
//安卓机物理返回键监听
function runtimeQuit(){
var first = null;
mui.back=function(){
if(!first){
first = new Date().getTime();
mui.toast('再按一次退出应用');
setTimeout(function(){
first = null;
},2000);
}else{
if(new Date().getTime() - first < 2000){
plus.runtime.quit();
}
}
}
}
移动端复制
//复制
function setMotion() {
var uesr = window.navigator.userAgent.toLowerCase();
if(uesr.indexOf("iphone") != -1) {
return true;
}
}
// 安卓复制
function copyToClip(text) {
var Context = plus.android.importClass("android.content.Context");
var main = plus.android.runtimeMainActivity();
var clip = main.getSystemService(Context.CLIPBOARD_SERVICE);
plus.android.invoke(clip, "setText", text);
mui.toast('复制成功!');
}
function iosCopyToClip(value) {
var UIPasteboard = plus.ios.importClass("UIPasteboard");
var generalPasteboard = UIPasteboard.generalPasteboard();
// 设置/获取文本内容:
generalPasteboard.setValueforPasteboardType(value, "public.utf8-plain-text");
var value = generalPasteboard.valueForPasteboardType("public.utf8-plain-text");
mui.toast('复制成功!');
}