Do not fire onExitFullscreen
when configuration changes are being applied
#5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By default Android will recreate activities (running their lifecycle methods in the process) when any of the following changes;
colorMode
).density
)fontScale
)fontWeightAdjustment
)grammaticalGender
)keyboard
)keyboardHidden
)layoutDirection
)locale
)mcc
)mnc
)navigation
)orientation
)screenLayout
)screenSize
)smallestScreenSize
)touchscreen
)uiMode
)Out of all those,
orientation
andscreenSize
are the most likely to change (they'll both change when rotating the device).The trouble is detection of leaving full screen mode is currently handled by
onDestroy()
, which Android will invoke when recreating the activity. As a resultonExitFullscreen
is called too early which means;isFullscreen
is set tofalse
.playerView
too early.There are 2 ways of solving this issue;
android:configChanges
inAndroidManifest.xml
and handle changes ourselves.isChangingConfigurations()
to determine why lifecycle methods likeonDestroy
are being called, and only runonExitFullscreen
whenfalse
.This PR implements (2) for the following reasons;
isChangingConfigurations()
is a stable API, available since API level 11 (Android 3.0).Granted,
android:configChanges
has been around for even longer.This change has been tested on a Pixel 8 with Android 14.