Repository navigation
KeepAwake
With this module you can keep the screen on indefinitely. Or, if you only need run native code, you can keep only de CPU on even if the screen turns off.
To use this library you will need to import:
import { KeepAwake } from 'react-native-androide';KeepAwake.screen();Take care with this, do not keep screen on if the user is away. Draining the battery will cause a bad user experience.
Call KeepAwake.freeScreen(); to allow the screen turn off.
Different from previous, this function needs a special permission: WAKE_LOCK.
To grant the required permission, add this line:
<uses-permission android:name="android.permission.WAKE_LOCK" /> to the Manifest File located in android\app\src\main\AndroidManifest.xml.
If this permission are not guaranteed the promises from KeepAwake.CPU() and KeepAwake.freeCPU () will be rejected.
KeepAwake.CPU();This function only keep native(Java) code running, you Javascript code will freeze, but the application will not be closed. This function return a Promise the will resolve with true and, will reject if any problem occur.
Use KeepAwake.freeCPU(); to allow the CPU to sleep again.