Preventing the rotation of the screen in Android

To prevent rotation of the screen in Android you can use one of two statements:
Android: screenOrientation = “portrait”
or
Android: screenOrientation = “landscape”
being included in the activity tag in the file AndroidManifest.xml.

Keeping the Android screen on

Sometimes you prefer to keep the Android screen on also in case of prolonged inactivity, this limit is usually set at 30 seconds, beyond which the screen turns off to increase the battery life.
This can be true for applications like watching movies, navigators, or even during the development phase of an application.
To keep the screen on for a particular Activity you can use the following statement:

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