Bug 24773 - Android - Application crash when restored after touching back button on MainPage (XF 1.3 pre1)
Summary: Android - Application crash when restored after touching back button on MainP...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.0
Hardware: Other Other
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-11-24 11:11 UTC by daniel.luberda
Modified: 2015-05-20 09:12 UTC (History)
5 users (show)

Tags:
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 daniel.luberda 2014-11-24 11:11:47 UTC
Xamarin.Froms 1.3.0 pre1 Android

1. Create a new application
 - create class which inherits from new Application class
 - then implement MainActivity.cs by inheriting from FormsApplicationActivity
 - In OnCreate method call Forms.Init and LoadApplication

2. Debug application. Minimize application by clicking Android Home button. Then restore it through task manager. It works ok. 
3. Minimize application by clicking Android Back button from MainPage. Then restore it through task manager. Crash:

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.NullReferenceException: Object reference not set to an instance of an object
[MonoDroid] at Xamarin.Forms.NavigationProxy.set_Inner (Xamarin.Forms.INavigation) <IL 0x00076, 0x0025a>
[MonoDroid] at Xamarin.Forms.Platform.Android.Platform.SetPage (Xamarin.Forms.Page) <IL 0x0009f, 0x0031b>
[MonoDroid] at Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage (Xamarin.Forms.Page) <IL 0x000b6, 0x0039f>
[MonoDroid] at Xamarin.Forms.Platform.Android.FormsApplicationActivity.SetMainPage () <IL 0x0000c, 0x00047>
[MonoDroid] at Xamarin.Forms.Platform.Android.FormsApplicationActivity.LoadApplication (Xamarin.Forms.Application) <IL 0x00035, 0x00117>



Possible dirty hack to get it working is to add this code to MainActivity.cs: 

		public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
		{
			if (this.ActionBar.Title == "YourMainPageTitle")
			{
				if (keyCode == Keycode.Back && e.RepeatCount == 0)
				{
					MoveTaskToBack(true);
					return true;
				}
			}
				
			return base.OnKeyDown(keyCode, e);
		}
Comment 1 Parmendra Kumar 2014-11-25 05:20:11 UTC
We have tried to reproduce this issue but not able to reproduce this. Could you please provide a sample app and detailed steps/screencast that demonstrate this issue, so that we can reproduce this issue at our end.

Also please let us know that you are getting this issue with android device or emulator?

Thanks
Comment 2 daniel.luberda 2014-11-25 05:22:10 UTC
Please read this:
http://forums.xamarin.com/discussion/comment/89844
Comment 3 Parmendra Kumar 2014-12-04 06:44:48 UTC
I have checked this issue with attached link in comment 2 and I am getting Unhandled Exception: System.NullReferenceException. 
Could you Please check the screencast and application output and let we now if you also getting same issue or I have missed anything.

Screencast:http://www.screencast.com/t/llkVnb1dFu8

ApplicationOutput:https://gist.github.com/Parmendrak/f3a97925a78c782a2e7a

Environment info:

Xamarin Studio 5.5.4 (build 15)
Xamarin.Android: 4.20.0.28 (Business Edition)
Mono 3.10.0 ((detached/92c4884)
Xcode 6.1 (6602)
Xamarin.iOS : 8.4.0.43 (Business Edition)
Xamarin.Mac : 1.10.0.18 (Business Edition)
Operating System : Mac OS X 10.9.4
Comment 4 daniel.luberda 2014-12-15 07:35:08 UTC
This bug is also present in 1.3.0 pre3 ... but instead of exception, user is getting empty page (without views). 

Screencast:
http://www.screencast.com/t/kIW7tJfFYNh3

Steps to reproduce: just a standard XF application (FormsApplicationActivity + Forms.Init + LoadApplication)
Comment 5 Rui Marinho 2015-05-20 09:12:40 UTC
Fixed in 1.3.5 or upper versions