Share via

Page.Disappearing and Page.Appearing will not be raised on android 13-API33

Fei Xu 490 Reputation points
2023-09-27T07:44:58.2466667+00:00

Page.Disappearing and Page.Appearing will not be raised on android13-API33

now how can i know app disappear and appear on android13

public partial class MainPage : ContentPage
{
	int count = 0;

	public MainPage()
	{
		InitializeComponent();
        this.Disappearing += MainPage_Disappearing;
        this.Appearing += MainPage_Appearing;
	}

    private void MainPage_Appearing(object sender, EventArgs e)
    {
        throw new NotImplementedException();
    }

    private void MainPage_Disappearing(object sender, EventArgs e)
    {
        throw new NotImplementedException();
    }
Developer technologies | .NET | .NET MAUI
0 comments No comments

Answer accepted by question author
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,166 Reputation points Microsoft External Staff
    2023-09-28T06:29:17.6333333+00:00

    Hello,

    now how can i know app disappear and appear on android13

    For the Disappearing and Appearing methods, the use case is page navigation events.

    Disappearing is raised when the page disappears due to navigating away from the page within the app. It is not raised when the app disappears due to an event external to the app (e.g. user navigates to the home screen or another app, a phone call is received, the device is locked, the device is turned off).

    For your use case, it is more recommended to use lifecycle events.

    Please refer to the following documentation and code sample:

    protected override Window CreateWindow(IActivationState activationState)
    {
        Window window = base.CreateWindow(activationState);
    
        window.Stopped += (s, e) =>
        {
            Console.WriteLine("Stopped");
        };
        window.Resumed += (s, e) =>
        {
            Console.WriteLine("Resumed");
        };
        return window;
    }
    

    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.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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