Skip to content

Files

brightness

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Mar 27, 2022
Sep 7, 2020
Mar 27, 2022
May 12, 2023
Sep 7, 2020
Jan 24, 2021
Sep 7, 2020
Jan 24, 2021
Mar 27, 2022
Apr 7, 2024
Sep 7, 2020
Sep 7, 2020

@nativescript/brightness

A plugin that get and set the device's brightness level.

Contents

Installation

npm install @nativescript/brightness

Required permissions for Android

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">
	...

Use @nativescript/brightness

Set the device brightness level

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,
});

Get the device brightness level

To get the device's brightness level, call the get() method on an instance of the Brightness class.

bightnessLevel : number = brightness.get()

API

Brightness class

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

BrightnessOptions interface

Property Default Description
intensity 100 Defines the desired brightness value, which should be a number between 0 and 100.

License

Apache License Version 2.0