I would like it to be disabled when I use in certain condition, such as during traveling with GPS.
-
1Look in your gps app for an option "do not turn off the screen" or "keep the screen on" or similar. Most of them do have it.– ΆνδραςCommented Jan 28, 2019 at 9:15
-
I worry that there is no such option on google map. But in case mine is different, can you help me please show how to do it?– AirCraft LoverCommented Jan 28, 2019 at 10:00
-
1No, Google Maps doesn't have it in map mode. But if you use it in navigation mode (which is not clear from your question), the screen won't turn off.– ΆνδραςCommented Jan 28, 2019 at 10:01
-
1There is an feature on the Developer options that, when enabled and connected to a power source, the screen won't turn off– esQmo_Commented Jan 28, 2019 at 11:01
-
I maybe lack of knowledge about Android. Can you please show me that one you mentioned available in navigation mode?– AirCraft LoverCommented Jan 28, 2019 at 13:39
4 Answers
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
.
- 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:cd /path/to/your/folder
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.
-
How to run this script? I have installed the Terminal Emulator, then I typed one by one your line, but I got error: /system/bin/sh: [86400: not found Commented Jul 28, 2019 at 7:21
-
@AirCraftLover I edited the post to show the steps on how to create and run the script Commented Jul 28, 2019 at 7:45
-
I copied and pasted the script into Notepad of Windows and I named as "timeout.sh" (without quote). Then I emailed it to my own email, then there I downloaded in my smart phone to /storage/emulated/0/Download. Then in Terminal Emulator I change the dir (cd) to the path, then I run command as: sh timeout.sh and then try again using command: sh ./timeout.sh. Both produced error: syntax error: 'done' unexpected. Then I deleted the "done" in the script, and I run again the command using sh and sh ./, and the command is: syntax error: 'done' unmatched. What probably the error? I use Android 4.4.4. Commented Jul 28, 2019 at 8:33
-
@AirCraftLover The error is simply because Windows and Unix systems (Android) don't save the end of file the same way :). Use the following command in the terminal to convert the file to the correct format:
awk '{ sub("\r$", ""); print }' timeout.sh > timeout1.sh
. The command strips Windows' EOL from timeout 1.sh and write everything else to timeout1.sh. Commented Jul 28, 2019 at 9:02 -
I was in this /storage/emulated/0/Download directory. Then I run your command, then the error message is: /system/bin/sh: awk: not found Commented Jul 28, 2019 at 13:36
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.