.NET MAUI - How to access the MainPage from the Android OnCreate() function

Vaclav Jedlicka 41 Reputation points
2022-09-18T13:05:04.277+00:00

In the MainActivity/OnCreate method, I would like to pass the URI of the incoming Intent to the instance of the MainPage class. How can I do that?

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

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 42,081 Reputation points Microsoft Vendor
    2022-09-19T02:29:39.687+00:00

    Hello,

    You need to override the MAUI App Lifecycle method to do it.

    Please refer to App lifecycle to get details and sample.

    Update:

    I've reproduced your issue.

    It is caused by something error in MAUI 6.0.4 and above, if I switched the MAUI version to 6.0.312, the project would run as expected.

    Therefore, it is recommended to post your issue in MAUI issues.

    Best Regards,

    Alec Liu.


    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 additional answers

Sort by: Most helpful

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.