Remove All Ads from XDA
Honor 9 Lite

[Q] Navigating My Activity Hierarchy - Troubleshooting

1 posts
Thanks Meter: 0
By Nsouth, Junior Member on 28th April 2014, 11:17 PM
Post Reply Email Thread
See the example hierarchy attached. There is a flow up and down. Using the app would go something like this:

Select Team 1 on the Home activity --> Activity A inflates based on the selection.
Select Player 2 on Activity A --> Activity B inflates based on the selection.
Select to Add a Stat on Activity B --> Activity C inflates and allows a stat to be added.

User returns to Activity B, which must maintain the Player 2 context and update based on C.
User returns to Activity A, which must maintain the Team 1 context and updated based on B.
User returns to Home, which must update based on A.

Click image for larger version

Name:	BBk1V.png
Views:	7
Size:	34.2 KB
ID:	2714479

My question is how to update an activity based on its child while maintaining the context supplied by its parent.

For example, let's focus on Activity B. It knows to inflate for Player 1 because this info was passed from Activity A in an intent.
  • If I were to go to Activity C and press Back, B wouldn't update.
  • If I were to go to C and press Up, B would crash because it would try to make a new instance and wouldn't know what player to inflate (defined in onCreate()).
I tried declaring B with a "singleTop" launchMode, but then it just restarts and doesn't update based on C's info. Based on my limited experience/research, I see the following options.
  1. Store an Activity's inflater variables as static (so they won't be "lost" when creating a new instance)
  2. Initiate my view inflation (via Fragment) in the Activity's onStart() method so that it would refresh when Restarting. (Would this help? What about the fact that all of my inflation happens inside of a fragment? I fear the Lifecycle gods.)

I'm new to a lot of this and would appreciate any help. Thanks!
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes