简体   繁体   中英

Android P onStart called before onActivityResult

I am trying the new Android P Developer Preview, and the secenario is as follows:

  1. I call Activity B from Activity A with startActivityForResult
  2. Finish Activity B with SetResult and go back to Activity A , the Activity Life cycle used to be (Prior to Android P Preview):
    1. onActivityResult
    2. onStart
    3. onResume

(Here also a post that confirms this order Execution order of OnActivityResult and OnResume ) answer from rndstr

  1. Now While testing the Android P Preview the Activity lifecycle is:

    1. onStart
    2. onActivityResult
    3. onResume

Android Documentation https://developer.android.com/reference/android/app/Activity#onactivityresult says only that onActivityresult should come before onResume , it says nothing about onStart

can anybody help ? is this a bug in Android P Preview or this is a new behavior? is there a good documentation for this?

I am using targetSDK: 23

Activity A is: SingleTask and Activity B is: SingleTop

It sounds to me like you've answered your own question!

The documentation says only that onActivityResult() will be called before onResume() , it says nothing about onStart() .

onStart() and onStop() are only called if your Activity is not visible. This means that if you launch another Activity and that Activity does not completely cover the screen, your Activity will NOT get the onStop() , onRestart() and onStart() calls anyway. Therefore you should not rely on them and you should not rely on the order in which they are called.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM