Skip to main content
Version: v1.0

hmSetting.setBrightness(brightness)

Sets the screen brightness of the current device, in the range [0, 100].

If auto-brightness is currently turned on and the brightness is automatically adjusted by the light sensor, the setBrightness function will have no real effect. You need to turn off auto-brightness first and then set the screen brightness.

If you exit the page, you need to consider whether you need to set the brightness back to the original one.

Type​

(brightness: number) => result

Parameters​

brightness​

DescriptionRequiredTypeDefault
Set the brightness of the current device, range [0, 100]Yesnumber-

result​

DescriptionType
result, 0 means the setting is successfulnumber

Code example​

const result = hmSetting.setBrightness(50)