back button in android using Quasar 0.16



  • I upgraded to quasar 0.16 from 0.14 recently, my app has a start page, and auto jumps to different pages based on some conditions, in the target page, I just want exit when back button is pressed, but the route is not “#/”.

    I found some behaviors were different with quasar v0.14, In 0.16:

    1. When using debug version(quasar dev -m cordova -T android), the back button works as expected, but I can not register backbutton event using following code:
      mounted () {
        if (this.$q.platform.is.cordova) {
          document.addEventListener('backbutton', this.onBackButton, false)
        }
        if (this.$store.getters.isFinished()) {
          this.$router.replace('/repo')
        }
      },
    

    onBackButton method never get fired when I pressed the back button.

    1. When using release version(quasar build -m cordova -T android), the back button behavior changed, I can not exit app when i am not in ‘#/’ route. seems it’s a new design of quasar 0.15, but why?

    And very strange, now the event works, then I can add this code to “fix” the behavior:

        onBackButton: function (e) {
          e.stopPropagation()
          navigator.app.exitApp()
        }
    

    But everything works fine in quasar 0.14. Maybe I misunderstood something?



  • @liuzhongshu - just to remind you: Quasar is moving very fast and we are closing in on our stable 1.0 release. 0.14 was a stage in the evolution of Quasar that I also enjoyed, but a lot has happened since then. Until we get to 1.0, EVERYTHING is subject to change and although the framework is pretty stable, you can expect some behaviours to change as we get bug reports and developer feedback.



  • @nothingismagick yes, I know that, quasar is great. I just want to know if any other one have same issue with me, or maybe I misunderstood something?



  • After several days of debugging, I found that onMessageFromNatives in cordova.js could not be triggered under the debug version(quasar dev) using quasar 0.16, I have created an issue on github.

    https://github.com/quasarframework/quasar/issues/2267



  • @liuzhongshu I have a similar problem after upgrading from 0.14 to 0.16. For me the back button is not working or only after you press it multiple times and then it jumps back multiple steps in the history. Did you see this problem too and have a solution? Getting pretty frustrated as I haven’t changed anything. Any insight would be greatly appreciated.





  • @dsky Your problem seems to be related to hardware, have you tried changing a mobile phone?



  • @liuzhongshu I have tried multiple phones with all the same result, I really believe it is a quasar 0.16 issue



  • @dsky https://forum.quasar-framework.org/topic/2481/quasar-quasar-cli-v0-17-aka-ssr-developer-preview/

    Quasar 0.17 refactors how the back button is handled. Please test this version (beta).

    cordova: {
      iosStatusBarPadding: true/false, // add the dynamic top padding on iOS mobile devices
      backButtonExit: true/false // Quasar handles app exit on mobile phone back button
    }


  • I find my issue is related with android version, with android 5.1, the problem exists, but under android 7, it does not exist.