OnActivityResult is called before onDestroy

Inside MainActivity.java, I make the following call:

Intent activity = new Intent(this, CameraDetectionActivity.class); startActivityForResult(activity, request); 

And at some point inside CameraDetectionActivity I run the following 2 lines (everything happens in the GUI thread):

 setResult(Activity.RESULT_OK); finish(); 

I would expect onDestroy to be called before onActivityResult in MainActivity, but they are called in reverse order. Any idea why this is happening?

+4
source share
1 answer

onDestroy is called at some point later and can be arbitrarily long. We want to resume the next event as soon as possible so that the user interface is there and then take care to stop and destroy the previous actions only after the user interface has switched.

+9
source

All Articles