Check out example codes for "android studio keep device awake". It will help you in understanding the concepts better.

Code Example 1

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

Code Example 2

window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)

Learn ReactJs, React Native from akashmittal.com