As others have already noted, onActivityResult () is called before onResume () when your activity restarts.
Diana Hackborn explains that onActivityResult () is called before onResume () to allow anything that can affect the user interface that must be received and accessible before updating the user interface (presumably to avoid double updating - once in onResume () without return result, then in onActivityResult (), adding the return result).
https://groups.google.com/forum/?fromgroups=#!topic/android-developers/3epIML7fjGw
One of the consequences of this is that any initializations that you may have decided to perform only inside onResume () (for example, initializing data from an external source that you need to be fresh), and not in onCreate (), would be uninitialized, if the call to onActivityResult () occurs as part of a restart of the application that was removed from memory by the operating system (since onResume () was not called before onActivityResult ()).
In this situation, onActivityResult () must be prepared to perform such initializations for any such variables that are used by onActivityResult ().
Of course, if the initializations required by the onActivityResult () function can be performed in onCreate (), and not in onResume (), then since onCreate () will be called on reboot before both onActivityResult () and onResume (), this would be The easiest way to get to the materials that you do not need to do every time the application is resumed. If, however, the data that you initialize comes from an external source, and you need it to be fresh, you can initialize such data in both onCreate () and onResume (), while onResume () checks the flag set in onCreate () to see if the data had just been initialized in onCreate), and then update it in onResume () only if they were not. Thus, some of them will always be available (at least from the moment the application was resumed).
Another way to handle this is to store the information returned by the onActivityResult () function in variables that will be retrieved with onResume () and processed there (after any required initializations have been performed onResume ()), instead of doing processing inside the body of onActivityResult () itself.
This feature is very documented, without any explanation or warning (in white papers) about the consequences of this somewhat unexpected sequence. It is also very easy to miss the problem during testing, because on a device with a lot of memory, which doesnβt have many applications running, the activity that causes startActivityForResult () (or its variants) can never be cleared from memory, waiting for it to start working, return the result via onActivityResult (), and therefore all initializations performed by onResume () will already be available, and therefore, the problem may not be detected.
Here is an informative study of some of the problems associated with this sequencing (including a warning about trying to use the Application object application to protect variables from its effects), complete with a UML sequence diagram with drawing:
http://steveliles.github.com/android_activity_lifecycle_gotcha.html