1

IMG:

I would like it to be disabled when I use in certain condition, such as during traveling with GPS.

  • 1
    Look 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. – Άνδρας Jan 28 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 Lover Jan 28 at 10:00
  • 1
    No, 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. – Άνδρας Jan 28 at 10:01
  • 1
    There is an feature on the Developer options that, when enabled and connected to a power source, the screen won't turn off – esQmo_ Jan 28 at 11:01
  • I maybe lack of knowledge about Android. Can you please show me that one you mentioned available in navigation mode? – AirCraft Lover Jan 28 at 13:39
2

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.

  • 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 – AirCraft Lover Jul 28 at 7:21
  • @AirCraftLover I edited the post to show the steps on how to create and run the script – Reddy Lutonadio Jul 28 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. – AirCraft Lover Jul 28 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. – Reddy Lutonadio Jul 28 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 – AirCraft Lover Jul 28 at 13:36
1

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.