2

Can someone clarify - if in my activity, I leave to call an intent via startActivityForResult (such as take a picture), when users return to my app, what is the entry point for that activity? Is it onCreate, onStart, or onResume?

Thanks!

Tyler
  • 29,539
  • 8
  • 19
  • 22
  • Check [this answer related to activity life cycle](http://stackoverflow.com/a/8516056/265167), this may help you i guess! – Yaqub Ahmad Dec 15 '11 at 07:50

2 Answers2

4

If the original activity is never stopped, it reenters via onResume(). If it is stopped it reenters via onRestart() -> onStart() -> onResume().

startActivityForResult shouldn't stop the original activity.

3

Normally, it will be onResume() followed by onActivityResult(). However it's possible, though unlikely, that the calling activity will have been killed at some point while the user worked with the other activity; this happens when the system runs out of memory, at which point it starts killing stuff, starting from the 'most inactive'. In that case, I imagine it would go through onCreate(), onStart(), onResume() and then finally onActivityResult().

The exact callback for onActivityResult() is:

protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 
    //Your code here
}
Steve Haley
  • 53,826
  • 17
  • 73
  • 84