Search code examples
appcelerator

Window not closing after handling back button


When I press the back button on the window, then it is not getting closed. If I remove the back button handle, then it is getting closed. Below is the code snippet.

$.myWindow.addEventListener("android:back", function() {
 // perform some action
});

Can someone please let me know as to why it is not closing?


Solution

  • You need to close the window manually if you handle the back button. For example the code should be:

    $.myWindow.addEventListener("android:back", function() {
     // perform some action
     $.myWindow.close();
    });
    

    This should resolve the issue.