title: Taro.getScreenBrightness(option)

sidebar_label: getScreenBrightness

Gets screen brightness.

Note

  • If the auto brightness adjustment feature is enabled in the Android system, the screen brightness will be automatically adjusted according to the light. And this API can only obtain the brightness value before the auto brightness adjustment, instead of the real-time brightness value.

Reference

Type

  1. (option?: Option) => Promise<SuccessCallbackOption>

Parameters

Option

Property Type Required Description
complete (res: any) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: any) => void No The callback function for a failed API call
success (res: Result) => void No The callback function for a successful API call

SuccessCallbackOption

Property Type Description
value number Screen brightness. Range: 0 (Darkest) to 1 (Brightest).

API Support

API WeChat Mini-Program H5 React Native
Taro.getScreenBrightness ✔️ ✔️