【小(xiǎo)編推薦】太原app開(kāi)發-ap∑&επicloud雙擊返回鍵退出

2015-09-10   |'•   發布者:梁國(gu≤₩λó)芳   |&nbs¥↓₹p;  查看(kàn):3320次

app開(kāi)發
 發現(xiàn)QQ群裡(lǐ)很(hěn)對(duì)群友(yǒu)÷♠$>就(jiù)問(wèn)監聽(tīng)返回鍵的(de)方法,那(nà)我就(jiù)分(fēn)享個(gè)安卓下(x↔∑ià)雙擊返回鍵退出應用(yòng)的(de)代碼:

  1. function exitApp(){
  2.       ↓±→  api.addEventList‍∏λener({
  3.       &'εnbsp;    δ≠γ; name: 'keyback'
  4.         }, functionΩ¶(ret, err){
  5.       &₽‌Ωnbsp;     api.to​÷ast({
  6.           &nbs&© ≠p;      &✔•★✔nbsp;  msg: '再按一(yī)次返回鍵退出'↓★'♦+api.appName,
  7.       &λ‍nbsp;       &>✔nbsp;    & ©Ω←nbsp;duration:2000,
  8.       &nγ₩≈γbsp;        &n♦♥‍bsp;    lo↑↑♠δcation: 'bottom'
  9.         &∞ nbsp;       });
  10.         &nb →sp;       
  11.          ©"​       api.addEventLis♥•↕tener({
  12.       ∏λ‌      &n£ ↓♦bsp;      ₹‍; name: 'keyback'
  13.           &nbs¶₹p;     }, functε★ion(ret, err){
  14.           &n♦πbsp;    &nε'≥₽bsp;    api.closeWidget₽£₽ ({
  15.        δ§      ♥±↓;          &nb$ sp;    id: 'A6960480793↔₽₽365',     //這(zhè)∑ ♥ 裡(lǐ)改成自(zì)己的(de)應用(yòng)ID♥₹≠
  16.         &nγ¶÷bsp;         &¶ Ωnbsp;       ₹£;  retData: {name:'closeε€≠​Widget'},
  17.      ÷₩​¶       &nbsγ≥αp;         &®‌‍§nbsp;     sile¶≤nt:true
  18.         &nbπ Ωsp;       ↓•≠      &≥βnbsp; });
  19.           ∑¶      });
  20.         &Ω₽nbsp;      &n₽≠bsp;
  21.         &nb®εsp;       setTimeout('←'function(){
  22.       ©£      &nbδ∏∏sp;     &n∞→♦bsp;     exitApp();
  23.          ≥₩;       },3000)
  24.         });♦<∏•
  25. }
複制(zhì)代碼


然後在需要(yào)監聽(tīng)的(de)頁面調用(yòng)  ¶exitApp();  ®∞就(jiù)行(xíng)了(le)。