Bug 4939 - ActivityGroup in TabActivity shuts down on Finish()
Summary: ActivityGroup in TabActivity shuts down on Finish()
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-05-08 00:14 UTC by Ian
Modified: 2013-12-05 18:34 UTC (History)
2 users (show)

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:

Description Ian 2012-05-08 00:14:49 UTC
I have a ActivityGroup which is hosted in a tab. This is to simulate a UINavigationCOntroller from iOS so that we can push and pop activities in a tab and use the back button to navigate backwards.

When the Finish is called on a child activity (near end of this code), the whole app gets closed and the device returns to home screen.  

Host this control in a tab to see.

Note this is a port of the project from Java: https://sites.google.com/site/ericbharlow/sample-code/TabSample.zip?attredirects=0&d=1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace Common.Android
	public class NavigationActivityGroup : ActivityGroup
		private List<string> mIdList;
		protected override void OnCreate (Bundle bundle)
			base.OnCreate (bundle);

			if (mIdList == null)
				mIdList = new List<String> ();

		public override void FinishActivityFromChild (Activity child, int requestCode)
			//base.FinishActivityFromChild (child, requestCode);
			LocalActivityManager manager = this.LocalActivityManager;
			int index = mIdList.Count () - 1;
			if (index < 1)
				Finish ();
			manager.DestroyActivity (mIdList [index], true);
			mIdList.RemoveAt (index);
			string lastId = mIdList [index];
			Intent lastIntent = manager.GetActivity (lastId).Intent;
			Window newWindow = manager.StartActivity (lastId, lastIntent);
			SetContentView (newWindow.DecorView);			
		public void StartChildActivity (string Id, Intent intent)
			intent.AddFlags (ActivityFlags.ClearTop);
			Window window = LocalActivityManager.StartActivity (Id, intent);
			if (window != null)
				mIdList.Add (Id);
				SetContentView (window.DecorView);
		public override bool OnKeyDown (Keycode keyCode, KeyEvent e)
			if (keyCode == Keycode.Back)
				return true;
			return base.OnKeyDown (keyCode, e);
		public override bool OnKeyUp (Keycode keyCode, KeyEvent e)
			if (keyCode == Keycode.Back)
				OnBackPressed ();
				return true;
			return base.OnKeyUp (keyCode, e);
		public override void OnBackPressed ()
			int length = mIdList.Count;
			if (length > 1)
				Activity current = LocalActivityManager.GetActivity (mIdList [length - 1]);
				current.Finish ();
Comment 1 GouriKumari 2013-05-14 17:43:46 UTC
Is it possible for you to attach a complete, small project that demonstrates this behavior. This will help us to efficiently confirm and fix the bug.
Comment 2 PJ 2013-11-19 17:04:23 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 3 PJ 2013-12-05 18:34:24 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.