Yeah this is a good pattern. In most cases it probably doesn't matter, but it's a general rule: during any kind of initialization, let the super class do their work first; during any kind of finalization, you do your work first.
On Wed, Mar 31, 2010 at 12:14 PM, patbenatar <[email protected]> wrote: > I'm not positive about this, but I have never run into any issues > doing it the following way: In any method that runs when something > starts [ie: onCreate, onResume], I call through to super FIRST, > allowing the system to start up whatever it needs to before I do > anything. On methods that run when it closes [ie: onPause] I call > through to super AFTER all my closing logic. This way just makes sense > to me... Maybe someone with more technical knowledge could explain > this more accurately :) > > -Nick > > > > On Mar 31, 2:49 am, HippoMan <[email protected]> wrote: > > In general, does it matter in an Activity if I put the call to > > super.onResume() at the beginning or the end of my own onResume() > > method? > > > > In other words, I can do this ... > > > > @Override > > public void onResume() { > > super.onResume(); > > // do my stuff > > > > } > > > > ... or this ... > > > > @Override > > public void onResume() { > > // do my stuff > > super.onResume(); > > > > } > > > > Does it matter which one I choose? And if so, why? > > > > Obvously, this probably depends on what "do my stuff" actually > > entails. However, I'm looking for an explanation of what > > super.onResume() actually does, so I can make an intelligent decision > > as to where is the best place to put it in my own onResume method. > > > > I guess the same question would also apply to the position of > > super.onPause(), super.onStart(), super.onRestart(), etc., in the > > appropriate method calls, but let's at least start this discussion > > with super.onResume(). > > > > Thanks in advance. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > > To unsubscribe, reply using "remove me" as the subject. > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

