I'm encountering some strange behavior when I close and re-open my app.
Let's start with a basic two-activity app:
[Activity(MainLauncher = true)]
public class Activity1 : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var btn = new Button(this);
btn.Text = "One";
btn.Click += (s, e) => this.StartActivity(typeof(Activity2));
SetContentView(btn);
}
}
[Activity]
public class Activity2 : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var btn = new Button(this);
btn.Text = "Two";
btn.Click += (s, e) => this.Finish();
this.SetContentView(btn);
}
}
Then follow these steps:
1. Set to release mode (not sure if it matters, but I always use
release)
2. Deploy to a device from Visual Studio
3. Tap Activity1's button to launch Activity2.
4. Press the Home key
5. Re-launch the app from a shortcut on the home screen (bug doesn't
seem to reliably repro if you re-launch it from the recently used app list)
After re-launching the app, I would expect to see Activity2 presented to the
user. Instead, it shows Activity1. But the problem is much worse than just
seeing the wrong activity, since if the user presses Back they actually go
back to Activity2! Going back again goes back to another copy of Activity1.
This shouldn't happen since Activity1 should be at the root of the app
(going back from it should exit the app) and nothing should go back *to*
Activity2 since it was the topmost activity. It's as if a new copy of
Activity1 is created and pushed onto the stack on top of the two activities
that already exist.
In this small repro app, I can only reproduce the bug when I launch the app
from Visual Studio. If I launch it from the home screen, everything works
as expected. However, it's important to note that this property isn't true
of my real app. It repros in my real app 100% of the time, no matter where
I launch it from. I haven't figured out why they're different, but since I
can repro it 100% of the time in this small app when launched from Visual
Studio I hope it's enough for you to find the issue.
I'm running 4.0.6. I don't think this happens in older versions since I
never saw this behavior before recently. I verified it still repros in
4.1.0, but I couldn't get 4.2.0 to work at all so I couldn't try it there.
I really hope this repros for you guys since this is an elusive one. I've
already burned way too much time trying to track this issue down.
Thanks for any assistance you can provide!
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid