question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

attachView() is not getting called after launch with locked orientation

See original GitHub issue

I’m using a usual stuff in Activity.onCreate():

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    val container = findViewById(R.id.controller_content) as ViewGroup
    conductorRouter = Conductor.attachRouter(this, container, savedInstanceState)
    Timber.e("onCreate, has root controller: ${conductorRouter.hasRootController()}")
    requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
    if (!conductorRouter.hasRootController()) {
      conductorRouter.setRoot(RouterTransaction.with(MyController()))
    }
  }

Steps to reproduce:

  1. Call setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) in Activity.onCreate()
  2. Rotate your device into a landscape mode prior to launching
  3. Launch application
  4. It launches rotated in portrait, as requested, but visually there’s no controller inside

And here’s why. The following sequence of calls was observed in logs

-- launch in landscape --
MyController  D  createPresenter
   Presenter  D  attachView
-- rotated to portrait by system --
   Presenter  D  detachView retainInstance=true
MainActivity  D  onCreate, has root controller: true

And nothing after this… That is: it seems that the first round of attach/detach was happening in the landscape mode, but then activity immediately was rotated by the system into a requested orientation - and here another onCreate happened - and that one was not followed by attach/detach

If I remove locked orientation stuff than everything goes smoothly:

-- launch in landscape --
MainActivity  D  onCreate, has root controller: false 
MyController  D  onCreateView
MyController  D  createPresenter
   Presenter  D  attachView
-- rotated to portrait by hand --
   Presenter  D  detachView true
MainActivity  D  onCreate, has root controller: true
MyController  D  onCreateView
   Presenter  D  attachView

I’m not sure if this is a bug or me doing something wrong, and if this is a bug, I’m not sure if it’s mosby-conductor one or Conductor one or even an Android one 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sockeqwecommented, Aug 19, 2016

Thanks for reporting, I will take a look next week

0reactions
sockeqwecommented, Oct 19, 2016

thanks @EricKuck for your feedback! I will close this for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

onActivityForResult not called on orientation change
I've been trying to start an camera activity from my app, to take and save a photo that will later be upploaded. I...
Read more >
Rotate the screen on your iPhone or iPod touch - Apple Support
Tap the Portrait Orientation Lock button to make sure that it's off. Turn your iPhone or iPod touch sideways. If the screen still...
Read more >
[expo-screen-orientation] Screen orientation does not lock or ...
We need to lock orientation to landscape in one view! (expo go works, but with expo run:ios or eas build its not working)....
Read more >
ScreenOrientation.lock() - Web APIs | MDN
The lock() property of the ScreenOrientation interface locks the ... Typically orientation locking is only enabled on mobile devices, ...
Read more >
How to Change iPhone Rotation Lock Without Opening ...
1. Launch the Settings app on your iPhone. 2. Tap Accessibility. 3. Under "Physical and Motor," tap Touch.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found