I have an ActionMode in my fragment that I want only to run in the portrait mode; so I called actionMode.finish() in the onConfigurationChanged() fragment callback to stop the ActionMode if the orientation in the landscape:
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
if (orientation == Configuration.ORIENTATION_LANDSCAPE)
actionMode.finish()
}
This does work but Android studio warns me that "Calling finish() within onConfigurationChanged() can lead to redraws".
Is there a better way to finish the ActionMode in landscape without having to worry about that redrawing?
For example you have two activities:
MainActivityandSecondActivity.Attributes in
Manifestshould be:MainActivitystartsSecondActivitywhen screen is rotated intoLANDSCAPE:SecondActivitychecks on create if current orientation isLANDSCAPE, otherwise it finishes:When attribute
configChanges="orientation|screenSize"is not present - activity will be recreated on each screen rotation, otherwise - methodonConfigurationChangedis called.