A plugin that get and set the device's brightness level.
npm install @nativescript/brightness
Add the following permission to the App_Resources/src/main/AndroidManifest.xml file:
<uses-permission android:name="android.permission.WRITE_SETTINGS"/><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="es.amplya.app_inventario">
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<application android:name="com.tns.NativeScriptApplication">
...
To set the device's brightness level, call the set() method on an instance of the Brightness class, passing it the BrightnessOptions object with the desired intensity value.
import { Brightness } from '@nativescript/brightness'
const brightness = new Brightness()
brightness.set({
intensity: 25
})
To get the device's brightness level, call the get() method on an instance of the Brightness class.
bightnessLevel: number = brightness.get()
| Method | Returns | Description |
|---|---|---|
set(options: BrightnessOptions) | void | Sets screen's brightness level to the desired intensity |
get() | number | Returns current screen brightness value as a number between 0 and 100 |
getNative() | number | Returns current native screen brightness value. iOS: a value between 0.0 and 1.0. Android: 0 and 255 |
| Property | Default | Description |
|---|---|---|
intensity | 100 | Defines the desired brightness value, which should be a number between 0 and 100. |
Apache License Version 2.0