Navigate to activity that expects additional features

I have actions A, B, and C in my application and they flow in that order. If I implement the Up button in C, I want it to return to B. The encoding of the code generated by Eclipse is:

@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // This ID represents the Home or Up button. In the case of this // activity, the Up button is shown. Use NavUtils to allow users // to navigate up one level in the application structure. For // more details, see the Navigation pattern on Android Design: // // http://developer.android.com/design/patterns/navigation.html#up-vs-back // NavUtils.navigateUpFromSameTask(this); return true; } return super.onOptionsItemSelected(item); } 

However, B expects additional functions to be transferred from A in its onCreate method. The connection between B and C is that C allows the user to set some parameters that affect the display of B. Currently, I am saving changes to C in onPause (). Should I end () C when the user presses Up instead of calling navigateUpFromSameTask (this)?

+7
source share
2 answers

If you intend to return from C back to B, your activity will be created again if you use standard launch mode. onSaveInstanceState will not (reliably) work .

Declare the start mode of your activity B as:

 android:launchMode="singleTop" 

in your AndroidManifest.xml if you want to get back to your business. See document here too .

+8
source

I suppose you have a similar problem with this ? In fact, if you are going to return from C back to B, then there is the possibility of calling onCreate () again. This means that the extra functions that you get from the intent will disappear, so you need to save them using onSaveInstanceState .

0
source

All Articles