//退出APP
function exitNowApp(){
$api.setStorage('isFullScreen',0);
//按两次退出应用
api.addEventListener({
name : 'keyback'
}, function(ret, err) {
//全屏时 需要发送事件 并关闭全屏
var isFullScreen = $api.getStorage('isFullScreen');
console.log("isFullScreen"+isFullScreen);
//如果全屏 只关闭全屏
if(isFullScreen == '1'){
api.sendEvent({
name: 'clickhome',
extra: {}
});
}else{
api.toast({
msg : '再点一次退出应用',
duration : 2000,
location : 'bottom'
});
api.addEventListener({
name : 'keyback'
}, function(ret, err) {
if($api.getStorage('isFullScreen' == "0")){
api.sendEvent({
name: 'clickhome',
extra: {}
});
}else{
api.closeWidget({
silent : true
});
}
});
}
setTimeout(function() {
}, 2000)
});
}
来源:CSDN
作者:songdewu
链接:https://blog.csdn.net/songdewu/article/details/80391403