Bug 27130 - Setting MainPage fails after resuming
Summary: Setting MainPage fails after resuming
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.2
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-02-17 05:40 UTC by Paul Diston
Modified: 2017-08-29 03:58 UTC (History)
9 users (show)

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

NavigationPageSample Same as 26771 (338.21 KB, application/octet-stream)
2015-02-17 05:40 UTC, Paul Diston
Zip Xamarin Logs (3.65 KB, application/octet-stream)
2015-02-17 06:42 UTC, Udham Singh

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:

Description Paul Diston 2015-02-17 05:40:06 UTC
Created attachment 9869 [details]
NavigationPageSample Same as 26771


Based on this bug https://bugzilla.xamarin.com/show_bug.cgi?id=26771, there is a slightly different scenario which is also problematic. Where resuming the application and trying to change the MainPage fails, with nothing happening.

**Steps to Reproduce:**

Use the attached Test Case project
1. Launch Application on Android
2. Press the Back hardware button (Make sure not to press home, use the back
3. Hold down the home or recent apps button (depends on your version of
4. Select Application from current running apps list to re-launch
5. Press Change Main Page Button
6. Nothing happens

**Actual Results:**

Nothing happens

**Expected Results:**

Should set Page 2 as MainPage

**Build Date & Platform:**

   XA 4.20
   XF 1.3.3-pre2
Comment 1 Udham Singh 2015-02-17 06:42:31 UTC
Created attachment 9873 [details]
Zip Xamarin Logs

I have checked this issue with the help of test steps given in bug description and able to reproduce the reported behaviour.

Adb Logcat : https://gist.github.com/Udham1/4e34236ac4384b454bb7
Application Output : https://gist.github.com/Udham1/e0fd59070fb01cc29961

Environment Info : 

Xamarin.Forms :

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

Xamarin   3.9.325.0 (96e7814)
Comment 2 Udham Singh 2015-02-17 07:11:35 UTC
An update to the above comment : I have checked this issue with android device Samsung Galaxy Note3 (android 4.4.2).
Comment 3 Paul Diston 2015-02-19 07:58:06 UTC
After further research I found the following forum post :-


In there it mentions the MoveTaskToBack method, so adding the following code to the attached sample's MainActivity seems to improve things:-

public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
	if (NavigationManager.CurrentNavigationPage.Navigation.NavigationStack.Count == 1)
		if (keyCode == Keycode.Back && e.RepeatCount == 0)
			return true;

	return base.OnKeyDown(keyCode, e);
Comment 4 adrianknight89 2016-10-12 22:33:39 UTC
I tested this in AppCompat with XF I can't duplicate it. If you submit an updated repro, I'd like to take a look.