Bug 1919 - Resuming app always reverts to first activity
Summary: Resuming app always reverts to first activity
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 1.9.2
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2011-11-07 16:59 UTC by randyficker
Modified: 2012-09-06 11:32 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Scratch.MultiActivity.zip (13.37 KB, application/zip)
2011-12-14 15:45 UTC, Jonathan Pryor

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 randyficker 2011-11-07 16:59:41 UTC
I ran a simple test:

1.	Create a fresh Mono for Android project.  Add a second activity, and make the button of the default activity launch the second activity.
2.	Make an identical app in Eclipse using pure Java.
3.	Launch the Java app, tap the button to go to the second activity.  Now press Home, then re-launch the app.  Note that the app comes up on the second activity.
4.	Launch the Mono for Android app, tap the button to go to the second activity.  Now press Home, then re-launch the app.  The app comes up on the first activity.

How can Mono for Android apps resume where they left off like Java apps do? 

This repros 100% of the time for me.  I'm testing with a Nexus One running Android 2.3.6.
Comment 1 Jonathan Pryor 2011-12-14 15:45:26 UTC
Created attachment 1044 [details]

Attached is a trivial sample project.

I was able to reproduce the issue with the attached project ~2 weeks ago, but now I am not. I suspect that 4.0.1 fixed it, but I have no idea how/why.

(I can now commence tearing out what's left of my hair.)
Comment 2 Jonathan Pryor 2011-12-14 15:45:42 UTC
Mark as Fixed as I can't repro with 4.0.1.
Comment 3 Atsushi Eno 2012-08-31 08:29:45 UTC
I could still reproduce this with Nexus 7 (4.1) and Galaxy Note (2.3.6).
Comment 4 Atsushi Eno 2012-09-06 04:52:27 UTC
I found some differentiator. When I launch MfA app from (default) launcher, the Activity transition is the same as Eclipse runs it. But if I do it with am:

adb -e shell am start -a android.intent.action.MAIN Scratch.MultiActivity/scratch.multiactivity.Activity1

It results in the issue described here (and that's what we do in MonoDevelop, maybe as well as VS).
Comment 5 Atsushi Eno 2012-09-06 05:47:22 UTC
monodevelop addin got the fix. VS to wait (but should not take long, just it needs to include tools fix).
Comment 6 Atsushi Eno 2012-09-06 06:46:07 UTC
It should be included in VS too.
Comment 7 Jonathan Pryor 2012-09-06 11:00:12 UTC
So if I understand this correctly, the fix is to add `-c android.intent.category.LAUNCHER`:

    adb shell am start -a android.intent.action.MAIN \
        -c android.intent.category.LAUNCHER \

I wonder why this is required...

That would explain why I couldn't repro, though, as I was usually manually launching from the Home screen, not from MonoDevelop...