setBrightness
Start from API_LEVEL
2.0
. Please refer to API_LEVEL.
Set the screen brightness of the current device. If the auto brightness setting is currently turned on, the brightness is automatically adjusted by the light sensor, calling setBrightness
will not take effect at this time, you need to use setAutoBrightness
to turn off the auto brightness and then set it again. Note: If you exit the current page, you need to consider whether you need to set the brightness back to the original brightness.
Type
function setBrightness(option: Option): Result
Simplified calling method
function setBrightness(brightness: number): Result
Parameters
Option
Property | Type | Required | DefaultValue | Description | API_LEVEL |
---|---|---|---|---|---|
brightness | number | Y | - | Screen brightness value, range 0 - 100 | 2.0 |
Result
Type | Description |
---|---|
number | If 0 is returned, success is indicated |
Example
import { setBrightness } from '@zos/display'
const result = setBrightness({
brightness: 50,
})
if (result === 0) {
console.log('setBrightness success')
}