My app has two activities: MasterActivity and DetailActivity.
MasterActivity has two visualization modes: list mode and map mode. An action bar item toggles between them.
I'd like to mantain the selected visualization mode when user goes into DetailActivity and comes back. In the beginning I used SharedPreferences but then user would get back his previous visualization mode even after a device boot or a long inactivity time, and that's not what I mean.
Then I switched to Bundle and onSaveInstanceState but, when user clicks on back button of DetailActivity, onCreate's Bundle is always empty so I can't restore the previous visualization mode and it always reverts to the list one.
App uses a Toolbar and AndroidManifest.xml is configured like that:
<activity
android:name=".ui.MasterActivity"
android:label="@string/title_activity_master"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.DetailActivity"
android:parentActivityName=".ui.MasterActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="it.returntrue.revalue.ui.MasterActivity" />
</activity>