Android Activity Lifecycle Explained

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

Thanks!

+2


a source to share


2 answers


If the original activity never stops, it returns via onResume (). If stopped, it returns with onRestart () -> onStart () -> onResume ().



startActivityForResult should not stop the original activity.

+4


a source


Typically this will be onResume () followed by onActivityResult (). However, it is possible, though unlikely, that the calling activity will be killed at some point while the user is working on another activity; this happens when the system runs out of memory, and at that moment it starts killing things, starting with the "most inactive" one. In this case, I am assuming it will go through onCreate (), onStart (), onResume (), and then finally onActivityResult ().

Exact callback for onActivityResult ():



protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 
    //Your code here
}

      

+3


a source







All Articles