7

Given the following situation (partially pseudo-code):

  1. User presses a button in Activity A which in turn executes this code:
    progressBar.setVisibility(VISIBLE) // by default is set as INVISIBLE in the layout
    startActivityForResult(ActivityB)
  1. User rotates his device

Is it possible that step 2 (rotating device) causes a configuration change which leads to the recreation of Activity A and therefore the progressBar to be hidden before Activity B is shown? I know that startActivityForResult is an asynchronous call, but I am not sure how it is implemented internally, therefore if the configuration change in Activity A can occur before Activity B is shown?

stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270
  • 1
    Personally, I'd try to set it up such that it doesn't matter either way. This feels like one of those things that might be different based on Android version. – CommonsWare Nov 21 '20 at 19:24
  • Why would you use a progressbar in A if you just started B? Is the bar even visible? How would you update it from B? I do not understand this construction. – blackapps Nov 21 '20 at 19:33
  • @blackapps I just switched the two lines to make it more intuitive. Starting Activity `B` takes longer than I would like it to do so I show a `ProgressBar`. While implementing it, I came up with the question if a configuration change could hide the `ProgressBar` before Activity `B` is shown. It's more about learning and curiousity than about an practical issue. – stefan.at.kotlin Nov 21 '20 at 19:39
  • 1
    @CommonsWare Practically seen I guess one won't notice a difference between restoring the `ProgressBar` on a configuration change (if that can happen) and not doing so, but I am wondering if it's possible at all that a configuration change can happen. If that's the case, I would implement the few lines for saving and restoring the loading state, otherwise I would skip it ;-) It's more about learning and curiousity of course, asking the question likely took longer than implementing it ;-) – stefan.at.kotlin Nov 21 '20 at 19:47

0 Answers0