Can onActivityResult()
theoretically be called before onCreate
? I know it can be called before onResume()
, but let's consider this extreme case:
What happens now? Does activity A get re-created before receiving the result, or does it receive the result before onCreate()
? Is this guaranteed to be in the same order each time?
You will commonly see this if you are opening an app to scan a barcode or take a photo or video. The Activity
you launch to do that requires a lot of resources so Android kills the OS process hosting your app.
When the Activity
you launched wants to return the result to your app, the following occurs:
Application
instance (or your app's custom one) and calls onCreate()
on thatActivity
that will get the result (the one that called startActivityForResult()
)onCreate()
on the new Activity
. The Bundle
passed to onCreate()
in this case is the Bundle
most recently used to the save the Activity
instance state (from onSaveInstanceState()
).onStart()
on the new Activity
onActivityResult()
on the new Activity
onResume()
on the new Activity