Search code examples
androidxamarinandroid-activityandroid-lifecycleonactivityresult

Is there a way to configure android app to receive activity result between onStart and onStop?


I see very odd sequence of events when compared to Android lifecycle overview. My app calls other activity (file selector) and waits for the result. Such events happen:

  • my app calls StartActivityForResult (file selector shows up)
  • OnStop is called
  • OnActivityResult is called
  • OnStart is called

The last two events looks like mixed order to me, because technically my app works (code inside OnActivityResult) while being stopped. It even sounds weird :-).

Did I do something wrong? Is there a way to configure my app/activity for "correct" order -- i.e. first being woke up and then get OnActivityResult?

Gingerbread 2.3 if this matters.


Solution

  • The order is correct.When OnStop is called,you will on the second activiy.At this time,OnActivityResult is not called,it was a callback when you do something like SetResult and finish the second activity,then the first activity will handle OnStart method.