安卓机物理返回键监听

  1. //安卓机物理返回键监听
  2. function runtimeQuit(){
  3. var first = null;
  4. mui.back=function(){
  5. if(!first){
  6. first = new Date().getTime();
  7. mui.toast('再按一次退出应用');
  8. setTimeout(function(){
  9. first = null;
  10. },2000);
  11. }else{
  12. if(new Date().getTime() - first < 2000){
  13. plus.runtime.quit();
  14. }
  15. }
  16. }
  17. }

移动端复制

  1. //复制
  2. function setMotion() {
  3. var uesr = window.navigator.userAgent.toLowerCase();
  4. if(uesr.indexOf("iphone") != -1) {
  5. return true;
  6. }
  7. }
  8. // 安卓复制
  9. function copyToClip(text) {
  10. var Context = plus.android.importClass("android.content.Context");
  11. var main = plus.android.runtimeMainActivity();
  12. var clip = main.getSystemService(Context.CLIPBOARD_SERVICE);
  13. plus.android.invoke(clip, "setText", text);
  14. mui.toast('复制成功!');
  15. }
  16. function iosCopyToClip(value) {
  17. var UIPasteboard = plus.ios.importClass("UIPasteboard");
  18. var generalPasteboard = UIPasteboard.generalPasteboard();
  19. // 设置/获取文本内容:
  20. generalPasteboard.setValueforPasteboardType(value, "public.utf8-plain-text");
  21. var value = generalPasteboard.valueForPasteboardType("public.utf8-plain-text");
  22. mui.toast('复制成功!');
  23. }