Android P onStart called before onActivityResult
Asked Answered
U

1

7

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

Urethroscope answered 22/5, 2018 at 12:16 Comment(0)
B
6

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.

Barimah answered 22/5, 2018 at 18:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.