Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 单击“上一步”按钮显示toast通知,再次单击该按钮将退出应用程序_Android_Jquery_Cordova_Toast_Back Button - Fatal编程技术网

Android 单击“上一步”按钮显示toast通知,再次单击该按钮将退出应用程序

Android 单击“上一步”按钮显示toast通知,再次单击该按钮将退出应用程序,android,jquery,cordova,toast,back-button,Android,Jquery,Cordova,Toast,Back Button,我正在创建我的cordova应用程序,在移动应用程序中单击默认后退按钮时,它会显示一个烤面包机通知,“再次点击以退出应用程序”,然后再次单击后退按钮,它会退出应用程序 我尝试了一些代码,但没有一个代码在应用程序中起作用 window.plugins.toast.showWithOptions( { message: "Tap again to exit the app", duration: 1500, // ms position: "bottom"

我正在创建我的cordova应用程序,在移动应用程序中单击默认后退按钮时,它会显示一个烤面包机通知,“再次点击以退出应用程序”,然后再次单击后退按钮,它会退出应用程序

我尝试了一些代码,但没有一个代码在应用程序中起作用

window.plugins.toast.showWithOptions(
    {
      message: "Tap again to exit the app",
      duration: 1500, // ms
      position: "bottom",
      addPixelsY: -40,  // (optional) added a negative value to move it up a bit (default 0)
      data: {'foo':'bar'} // (optional) pass in a JSON object here (it will be sent back in the success callback below)
    },
    // implement the success callback
    function(result) {
      if (result && result.event) {
        console.log("The toast was tapped or got hidden, see the value of result.event");
        console.log("Event: " + result.event); // "touch" when the toast was touched by the user or "hide" when the toast geot hidden
        console.log("Message: " + result.message); // will be equal to the message you passed in
        console.log("data.foo: " + result.data.foo); // .. retrieve passed in data here

        if (result.event === 'hide') {
          console.log("The toast has been shown");
        }
      }
    }
  );
预期结果:在移动应用程序中单击“默认后退”按钮时,应显示“再次点击以退出应用程序”的烤面包机通知,然后再次单击“后退”按钮时,应退出应用程序。
实际结果:它不显示任何toast通知消息。

您可以创建如下逻辑:

int-isTouched=false;
公共无效BTN单击(视图){
如果(isButtonTouched)//退出
else isButtonTouched=true(并显示您的祝酒词)
}