Skip to content

Commit

Permalink
ClassifyActivity: Use launchMode=singleTop.
Browse files Browse the repository at this point in the history
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 da13474
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down

0 comments on commit da13474

Please sign in to comment.