One note about the above solution provided by quintin-balsdon:
it is important to use the version of Settings.Global.getFloat
that takes a default value, as it appears that (on emulators at least) if 'Remove animation' has never been switched on on a given device, then (at least) the setting for key Settings.Global.ANIMATOR_DURATION_SCALE
won't exist, and this code will result in an exception.
I'd therefore suggest:
fun Context.animationsEnabled(): Boolean =
!(Settings.Global.getFloat(contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f) == 0f
&& Settings.Global.getFloat(contentResolver, Settings.Global.TRANSITION_ANIMATION_SCALE, 1.0f) == 0f
&& Settings.Global.getFloat(contentResolver, Settings.Global.WINDOW_ANIMATION_SCALE, 1.0f) == 0f)