• Elie Todjom
        Has successfully completed the online course Basics (100)
      2 years ago #34416

      Hello Simplifier Community,

      i have implemented the navigate back on the Android Client but each time I press it, it navigates twice back instead on one time.
      Example: I Open: HomePage –> Listpage –> DetailPage and then press the Android BackButton and the navigation leads me to HomePage instead of ListPage.

      I first register the Backbutton and attach a customEvent to it like this:

      if (device.platform && device.platform === "Android") {
         document.addEventListener("backbutton", onBackButtonPress.bind(this), false);
         sap.ui.getCore().byId("Application").attachNavigate(function(oEvent) {
           this.getGlobals().setVar("gvCurrentScreen", oEvent.getParameter("toId"));
         }.bind(this));
      }
      
      function onBackButtonPress() {
         this.callCustomEvent("onHardwareBackButtonPress");
      }
      

      Later on the onHardwareBackButtonPress CustomEvent will call navContainerNavigation from SF_HELPER with this code:

      this.getView().byId(oPayload.navContainerId).to(this.getView().getId()+"--"+oPayload.navigationGoalId);
       fnSuccess();
      

      But the navigation always happen twice.

      Elie Todjom
          Has successfully completed the online course Basics (100)
        1 year ago #35167
        Up
        1
        Down
        ::

        I have solve the Problem by registering the BackButton using the the ScreenEvent ‘OnbeforeFirstShow’ and not ‘onAfterRendering’ of the main page.

        Jennifer Häfner
            Has successfully completed the online course Intermediate (200)
            Has successfully completed the online course Advanced (300)
            Has successfully completed the online course Basics (100)
            Has successfully completed the online course Advanced (310)
            Has successfully completed the online course Advanced (320)
            Has successfully completed the Intermediate Certification
            Has successfully completed the Advanced Certification
          2 years ago #34435
          Up
          0
          Down
          ::

          Hi Elie,

          You can check if the function ‘onBackButtonPress’ (and therefore, the custom event ‘onHardwareBackButtonPress’) is really executed twice everytime the back button is pressed, or if the issue is that the navigationGoalId contains the wrong screen name.

          This information is helpful to find the cause of this issue.

          Elie Todjom
              Has successfully completed the online course Basics (100)
            2 years ago #34436
            Up
            0
            Down
            ::

            I made a mistake it is this the Back navigation I’m using. So there is no navigationGoalId. The onHardwareBackButtonPress is call ones.

            this.getView().byId(oPayload.navContainerId).back();
            fnSuccess();
            

            Thank you.

            Elie Todjom
                Has successfully completed the online course Basics (100)
              2 years ago #34533
              Up
              0
              Down
              ::

              Hello Jennifer,

              the onBackButtonPress itself is executed once but the backTo() Methode Twice. The StackPage is clear Twice and is really executed twice and I can see it on my device Screen. It first goBack to the previous page and go Back once again.

              I did a screen Shot of the call stack , form the moment the ‘onHardwareBackButtonPress’ is call.

              Thank you.

              Attachments:
              You must be logged in to view attached files.
              Jennifer Häfner
                  Has successfully completed the online course Intermediate (200)
                  Has successfully completed the online course Advanced (300)
                  Has successfully completed the online course Basics (100)
                  Has successfully completed the online course Advanced (310)
                  Has successfully completed the online course Advanced (320)
                  Has successfully completed the Intermediate Certification
                  Has successfully completed the Advanced Certification
                2 years ago #34549
                Up
                0
                Down
                ::

                Hi Elie,

                Could you provide us with a small sample application where this behaviour is shown? This way, it is easier for us to check what’s the issue here. Thanks!

              Viewing 6 posts - 1 through 6 (of 6 total)

              You must be logged in to reply to this topic.