attachView() is not getting called after launch with locked orientation
See original GitHub issueI’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:
- Call
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
inActivity.onCreate()
- Rotate your device into a landscape mode prior to launching
- Launch application
- 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:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for reporting, I will take a look next week
thanks @EricKuck for your feedback! I will close this for now.