npm install @nativescript/brightness
Note
This plugin requires <uses-permission android:name="android.permission.WRITE_SETTINGS"/> to be added in the AndroidManifest.xml.
To use the plugin, you should first import it.
// TypeScript
import { Brightness } from '@nativescript/brightness'
To set the brightness level of the device, call the set() method passing it the BrightnessOptions object with the desired intensity value.
// TypeScript
const brightness = new Brightness()
brightness.set({
intensity: 25
})
The intensity value can range from 1 to 100.
To get the device's brightness, call the get() method.
bightnessLevel: number = brightness.get()
| Method | Description |
|---|---|
set(options: BrightnessOptions) | Sets screen's brightness to the desired intensity |
get() | Returns current screen brightness value as a number between 0 and 100 |
getNative() | returns current screen brightness value as returned from the native api: between 0.0 and 1.0 for iOS and 0 and 255 for android |
| Property | Default | Description |
|---|---|---|
| intensity | 100 | defines the desired brightness value, which should be a number between 0 and 100. |
Apache License Version 2.0