Android - How do I disable screen timeout of Android?

1. Use a script

You can use a script via the terminal to simulate a long action and prevent the screen from timing out. Create the script below and run via Terminal Emulator on your phone. It simulates pressing the letter r and Enter, then wait for a second before repeating the process for the number of times you choose with i.

  1. Create a file and put the following inside of it.
#!/system/bin/sh

i=86400 #Put a big number here

while [ $i -gt 0 ]
do

i=$(( $i - 1 ))
input keyevent 46 #Write the letter r
input keyevent 66 #Simulate Enter key on the keyboard
sleep 1           #Do nothing for 1 second

done
  1. Save the file, give it a name for example test.sh. Open the terminal and navigate to the folder where the file is saved (if you don't know the path, use your file manager to get the path) with the command:

    cd /path/to/your/folder

  2. Then execute the command:

    sh test.sh

The script will start running. When you no longer need it to run, just close the terminal.

2. Use an app

Caffeinate add a tile in the quick settings. In Caffeinate Settings, click on Caiffeine Tile, enable "Skip To Infinite Mode". Open the quick settings, click on the app tile. The screen should stays on until you press the tile again or click cancel on its notification.


If it's sufficient for you to only keep screen on when charging, you can turn on the Stay awake option in Developer options.

To do this:

  1. Open Settings, navigate to About [device] (tablet, phone etc.)
  2. Find Build number entry there. If there's none, it may be in Software information subsection.
  3. Tap Build number 7 times
  4. Make sure that a message pops up saying that you've become a developer (or that developer mode is already enabled)
  5. Go back to Settings main menu
  6. Find the newly-appeared Developer options item
  7. Turn on Stay awake option

The app MacroDroid has a feature to set screen timeout to never. I did not test it for long but the app is free, so you can give it a try.

Install the app and enable the permission "modify system settings". Afterwards, setup a macro like this:

Trigger: setup a Trigger of your liking.

Action: Screen Timeout -> never

Constraint: only if you need, otherwise, leave untouched.

Now, whenever the condition for the macro would be fulfilled/triggered the action would run and timeout for screen would be changed to never.

To change the timeout after your work is done, say you're done with Maps app, you need another macro which would work for the rest of your phone's usage.

The trigger is I believe needs dependent. You can try with app launch and closure based triggers, optionally coupled with some constraints.