I am using Tabgroupactivity in Xamarin to develop a droid app. I have a TabGroupActivity with 4 child activities.
The OnResume() is not being called in any of the child activities.
Can Anyone please help me with the right solution why is it not being called!! or Is there any fault in my code?
TabGroupActivity.cs
namespace RB.Droid
{
[Activity (Label = "TabGroupActivity")]
public class TabGroupActivity : ActivityGroup
{
private List<string> _idList;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
if (_idList == null)
_idList = new List<string> ();
}
public void StartChildActivity (string id, Intent intent)
{
intent.AddFlags (ActivityFlags.ClearTop);
var manager = new LocalActivityManager (this, false);
var window = MainTabActivity.localActivityManager.StartActivity (id, intent);
if (window != null) {
_idList.Add (id);
SetContentView (window.DecorView);
}
}
public override void FinishActivityFromChild (Activity child, int requestCode)
{
var manager = new LocalActivityManager (this, false);
var index = _idList.Count - 1;
if (index < 1) {
Finish ();
return;
}
MainTabActivity.localActivityManager.DestroyActivity (_idList [index], true);
_idList.RemoveAt (index);
index--;
var lastId = _idList [index];
var lastIntent = MainTabActivity.localActivityManager.GetActivity (lastId).Intent;
var newWindow = MainTabActivity.localActivityManager.StartActivity (lastId, lastIntent);
SetContentView (newWindow.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 ()
{
var length = _idList.Count;
if (length > 1) {
var manager = new LocalActivityManager (this, false);
var current = MainTabActivity.localActivityManager.GetActivity (_idList [length - 1]);
FinishActivityFromChild (current, 0);
}
}
}
}
SettingsActivityGroup.cs
namespace RB.Droid
{
[Activity (Label = "SettingsActivityGroup")]
public class SettingsActivityGroup : TabGroupActivity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Create your application here
StartChildActivity ("Settings", new Intent (this, typeof(Settings)));
}
}
}
Settings.cs
namespace RB.Droid
{
[Activity (Label = "Settings")]
public class Settings : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Create your application here
TextView tv = new TextView (this);
tv.Text = "Settings";
SetContentView (tv);
}
protected override void OnResume ()
{
base.OnResume ();
Toast.MakeText (this, "ON RESUME NOT CALLED", ToastLength.Long);
}
}
}