1.2.0 • Published 7 years ago
react-native-keep-screen-on v1.2.0
react-native-keep-screen-on
Allows for the selective toggling of the KEEP_SCREEN_ON flag (Android) and the setIdleTimerDisabled flag (iOS).
Installation
npm install react-native-keep-screen-on --save
Configuration
With rnpm
Just run rnpm link react-native-keep-screen-on
Manually
In settings.gradle
add the following lines:
include ':KeepScreenOn'
project(':KeepScreenOn').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keep-screen-on/android')
In build.gradle
add the following line:
compile project(':KeepScreenOn')
< 0.29 : In MainActivity.java
add the following lines:
import com.gijoehosaphat.keepscreenon.KeepScreenOnPackage;
new KeepScreenOnPackage(this)
>= 0.29 : In MainApplication.java
add the following lines:
import com.gijoehosaphat.keepscreenon.KeepScreenOnPackage;
new KeepScreenOnPackage(this)
Example usage:
import KeepScreenOn from 'react-native-keep-screen-on'
...
//Keep screen on...
KeepScreenOn.setKeepScreenOn(true)
//Reset to default behavior...
KeepScreenOn.setKeepScreenOn(false)