diff --git a/src/Plugin.Maui.ScreenBrightness/ScreenBrightness.android.cs b/src/Plugin.Maui.ScreenBrightness/ScreenBrightness.android.cs index 432f757..c52d09d 100644 --- a/src/Plugin.Maui.ScreenBrightness/ScreenBrightness.android.cs +++ b/src/Plugin.Maui.ScreenBrightness/ScreenBrightness.android.cs @@ -10,13 +10,22 @@ public float Brightness { get { - if (Platform.CurrentActivity is null) - { + var activity = Platform.CurrentActivity; + if (activity is null) { return 0; } - return Settings.System.GetInt(Platform.CurrentActivity.ContentResolver, - Settings.System.ScreenBrightness); + var window = activity.Window; + if (window is null) { + return 0; + } + + var windowBrightness = window.Attributes?.ScreenBrightness ?? 0; + if (windowBrightness < 0) { + return Settings.System.GetInt(activity.ContentResolver, Settings.System.ScreenBrightness) / 255f; + } + + return windowBrightness; } set