Bug 40722 - Using FormsAppCompatActivity calls OnDisappearing on device sleep
Summary: Using FormsAppCompatActivity calls OnDisappearing on device sleep
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.0.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-04-27 00:20 UTC by Joshua Novak
Modified: 2016-12-01 13:25 UTC (History)
8 users (show)

Tags: Android ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Joshua Novak 2016-04-27 00:20:16 UTC
When you add FormsAppCompatActivity the OnDisappearing method is called when the device sleeps, but OnAppearing is not called on device resume. If you use the normal FormsApplicationActivity OnDisappearing is not called when the device sleeps, which is how it should be.

Here is a Google Drive link to an example project. If you just run the project, click page 3, then watch the debug log. When you sleep the device you'll see the message "ON DISAPPEARING!!!", this should only happen when you leave the page.

https://drive.google.com/file/d/0B68aZqcn2sxXSWY0aWpHVGZfYU0/view?usp=sharing

Note: This is a huge issue since it breaks any app using FormsAppCompatActivity. Please fix as soon as possible. I have to delay my app because of this.
Comment 1 E.Z. Hart [MSFT] 2016-05-02 20:59:25 UTC
Confirmed - the behavior is not consistent between FormsApplicationActivity and FormsAppCompatActivity.
Comment 2 Joshua Novak 2016-05-02 22:26:33 UTC
This seems to be fixed in Xamarin.Forms 2.2
Comment 3 Björn Bentmar 2016-05-25 11:19:37 UTC
In XF 2.2 The OnAppering/Dissapearing is extremely broken. Every page in you navigation stack will trigger onappering when coming back from background. And every page will also trigger dissapearing when entering background, Or changing activity (for example taking picture with Xam.Plugin.Media)..
Comment 5 Samantha Houts [MSFT] 2016-10-12 22:07:52 UTC
Should be fixed in 2.3.4-pre1. Please note that you will need to opt in to the fix. 

using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific.AppCompat;

...

Application.Current.On<Android>()
                            .SendDisappearingEventOnPause(false)
                            .SendAppearingEventOnResume(false);


See https://github.com/xamarin/Xamarin.Forms/pull/450 for details. Thank you!