Permalink
Browse files

ClassifyActivity: Use launchMode=singleTop.

So the Up button (from Help/Examples, or List, for instance) is more
like the back button. Otherwise, Up navigation (correctly) ignores
the back stack and just creates a new instance. But our
ClassifyActivity has lots of state that we don't want to lose.
Alternatively, we could have used FLAG_ACTIVITY_CLEAR_TOP when
navigating up, but this seems simpler.

I do wonder exactly how this is dealt with in standard apps,
such as when writing an email, pressing a button to launch a photo
chooser activity and then pressing Up to come back, without losing
the contents of the email. However, I cannot find a real-world
example like that that actually has an Up button in the
helper activity.
  • Loading branch information...
murraycu committed Dec 16, 2014
1 parent f4c128e commit da1347454e0c0f2d7e6c9dd220931e1bd8baeb53
Showing with 7 additions and 1 deletion.
  1. +7 −1 app/src/main/AndroidManifest.xml
@@ -48,9 +48,15 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.murrayc.galaxyzoo.app.ClassifyActivity" />
</activity>

<!-- We use the app name because this is the main activity. -->
<!-- We use launchMode="singleTop" so the Up button (from the Help/Examples screen, for
instance, takes us back without losing the half-done classification. Otherwise,
Up would create a new instance, because Up is meant to ignore the back stack. -->
<activity
android:name=".ClassifyActivity"
android:label="@string/app_name" > <!-- We use the app name because this is the main activity. -->
android:label="@string/app_name"
android:launchMode="singleTop">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

0 comments on commit da13474

Please sign in to comment.