Issue
Checking some legacy code I've found this snippet:
@Override
public void onResume() {
if (!isFinishing()) {
...
}
super.onResume();
}
despite the super.onResume() call at the end of the method, which is discouraged:
Note: Your implementation of these lifecycle methods must always call the superclass implementation before doing any work, as shown in the examples above http://developer.android.com/guide/components/activities.html
I'm concerned about the if (!isFinishing()) call, does this have sense? as I can see checking Activity code mFinished variable is set to true only on finish() and finishActivity(), can, through the Android Lifecycle, to be resumed an activity which is being destroyed?
Thanks in advance.
Solution
Finally, the legacy code was calling finish() under some circunstances at the onCreate() method. But taking a look at onCreate() javadoc:
You can call finish() from within this function, in which case onDestroy() will be immediately called without any of the rest of the activity lifecycle (onStart(), onResume(), onPause(), etc) executing.
So, this isFinishing() call is useless inside onResume()
Answered By - Guillermo Merino
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.