OnBackButtonPressed() is not triggering.

Vaibhav Methuku 80 Reputation points
2024-09-19T04:44:04.6333333+00:00

I'm working with the Android - Maui application, I had overridden the OnBackButtonPressed() method in the page, unfortunately on clicking on hardware back button in android the method is not getting triggered and the application is closing.

Thanks.
Vaibhav Methuku.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,541 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 76,001 Reputation points Microsoft Vendor
    2024-09-19T08:38:34.4833333+00:00

    Hello,

    I had removed that piece of code from the manifest, It starts working normally, thanks

    Please remove android:enableOnBackInvokedCallback=true in the <Application> tag of AndroidManifest.xml ?

    If move it, OnBackButtonPressed() could be executed.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.