I would like it to be disabled when I use in certain condition, such as during traveling with GPS.
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
- 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
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:
Then execute the command:
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:
- Open Settings, navigate to About [device] (tablet, phone etc.)
- Find Build number entry there. If there's none, it may be in Software information subsection.
- Tap Build number 7 times
- Make sure that a message pops up saying that you've become a developer (or that developer mode is already enabled)
- Go back to Settings main menu
- Find the newly-appeared Developer options item
- 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.
If you are on LineageOS there is a custom tile called Caffeine which you can press repeatedly to increase screen timeout to infinity.
An app to replicate this is Caffeinate. Nougat (7.0+) is required to enable the quick settings tile.