Where to find hibernation in the phone what. Sleep lock for Android. Using sleep locks by apps

Calculator 27.09.2020
Calculator

A familiar situation: you read some information from the smartphone screen, and the display fades out at that moment. And what if it takes not a few seconds to read, but much more? It is clear that the constant pressing of the power button is annoying, to put it mildly.

How to make sure the Android screen does not go out? It turns out that the situation is not as critical as it might seem. There are several ways to solve it, which we will talk about now.

To adjust the screen off of your phone using the preinstalled tools, you need to go to " Settings", Open the section" Screen", Select the item" Sleep mode"And set there a comfortable" wakefulness "time for your smartphone, after which the screen will go blank, or remove the sleep mode altogether by checking the appropriate line:

How to disable screen timeout using third-party software

I don't think it's worth going into details about what the "Sleep mode" function is for, or the screen off after a certain period of time (timeout from English timeout). It is clear that if the smartphone is constantly in active mode, then the battery charge will begin to tend to zero too quickly.

In this case, the problem can be easily solved using special utilities.

Hold Screen On Demo

This program will not let the screen go out while you are looking at it. With the help of the front camera, Hold Screen ON catches your gaze and prevents your smartphone from falling asleep. When you stop looking at the screen, it fades out and, accordingly, the consumption of resources stops.

It is possible to bind the utility to a specific application, and then the phone screen will not go out, defining your eyes in this application, however, if your camera will work in another application, the program will have to wait until it becomes free.

Owners of Samsung Galaxy S3 use this function without installing the utility, since this model has it by default, and if you have a simpler device, you just need to download Hold Screen ON:

KeepScreen (now free)

Another good app that does an excellent job of disabling the timeout. Unlike the previous one, Keep screencontrols the position of the vehicle using the built-in gyroscope. Therefore, when you hold your gadget in your hands, the utility, given its tilt angle relative to the horizontal axis, will not let the screen go out.

In addition, there is also an option to block the screen off on the Android device for selected applications. To do this, after specifying the desired program, click " Start / stop service“, And on the phone, set the interval of 30 seconds in the screen blanking sensor (see the first screenshot).

Keep Screen takes good care of the smartphone's resources and works in the background, to do this, click “ On", And after that" Save and restart app».

Important! If you turn off (lock) the device using the power button while the program is running, then after thirty seconds the screen turns on and does not go out. Therefore, before you lock the gadget with the power button, you need to close the application or simply return to the main desktop.

On today's topic, we have nothing more to add, and, of course, it is up to you to judge how useful the information provided was. Good luck!

A long time ago, when Android was not yet mainstream, any developer could write an application that can safely hang in the background and communicate with the server in real time. But the further, the more stringent energy conservation techniques are used by Google, and today it is not so easy to implement a network real-time application. However, there are a few tricks that can help you do this.

Let's imagine that we have an application, and it, in turn, has a service that must constantly hang in the background, process commands received from the network server, and send responses. Communication with the server, as it should be for mobile devices, is supported using long poll requests, that is, the application connects to a remote server and waits for it to send something in response, and then reconnects and waits again. This is an efficient and very battery-saving method, which is also used in the push-notification mechanism of Android itself.

In theory, everything looks great, the architecture of the application is absolutely correct, but if you start testing it, some very unpleasant moments will be revealed.

Android power saving modes

In Android 4.4–5.1 (we will not consider the versions below - they are rapidly becoming obsolete), the service will work and instantly respond to server requests, but only as long as the screen is on. A few seconds after the screen turns off, the smartphone will go into sleep mode (suspend), and the interval between the sending of the request and the response of our application will be about a minute. This is the period between maintenance wakes of the device, and we cannot influence it.

In Android 6.0-7.1, the situation will be about the same, but after about an hour, the smartphone will switch to the so-called. After that, you can either not receive a response from the application at all, or receive an hour or two later. And all because in Doze mode, the smartphone actually does not allow third-party applications and their services to work and completely cuts off their access to the Network. They can only get control for a short period of time, an hour after switching to Doze mode, then two hours, four hours, with an increasing increase in the intervals between awakenings.

The good news is that Doze works system-wide and turns on an hour after the screen turns off and only if you don't touch the smartphone (in 7.0-7.1 you can touch it), but turns off immediately after unlocking the smartphone, connecting to the charger or moving the smartphone (again, not in 7.0-7.1). That is, we can hope that our service will work normally at least during the day.

The bad news is that, in addition to Doze, Android 6.0-7.1 has another power saving mechanism called App Standby. It works like this: the system monitors which applications the user uses, and applies the same restrictions to rarely used applications as in the case of Doze mode. When connected to a charger, all applications put into Standby mode receive an amnesty. Standby mode does not apply to applications that have notification or administrator rights (not root).

In total, there are three mechanisms in Android at once that you will have to fight:

  • Suspend - normal power saving mode, may slow down receiving a response from the device by about one minute;
  • App Standby - aggressive power-saving mode that can slow down the response for a day;
  • Doze is an aggressive system-wide power saving mode that applies to all applications.

All these power saving modes can be bypassed, but the further into the forest, the more crutches and inconveniences for the user, so we will consider several options for bypassing energy saving mechanisms, from the most light to hardcore.

Scenario 1. A small delay in response is not critical, the transition to Doze is not critical

In this scenario, you have an application for which a response delay of up to one minute is not critical, and the transition of the smartphone to aggressive power saving mode is not at all scary. All you need is to prevent the system from sending the application into Standby state.

The two easiest ways to accomplish this are to either bring the service to the foreground (foreground service) or give the application device administrator privileges. Let's start with the first option.

Foreground service

Foreground service in Android terminology is a service that has a notification in the curtain. The system treats such services much more carefully. For example, if there is not enough memory, it will be killed last, it will not be killed when you swipe an application in the menu for managing running applications, and yes, Standby mode will not be applied to it.

It is very easy to create a foreground service. It is enough to insert the following lines into the service code:

Intent notificationIntent \u003d new Intent (this, ExampleActivity.class); PendingIntent pendingIntent \u003d PendingIntent.getActivity (this, 0, notificationIntent, 0); Notification notification \u003d new Notification.Builder (this) .setContentTitle (getText (R.string.notification_title)) .setContentText (getText (R.string.notification_message)) .setSmallIcon (R.drawable.icon) .setContentIntent (pendingIntent) .setTicker (getText (R.string.ticker_text)) .build (); startForeground (0, notification);

This example creates a notification, when tapping on which ExampleActivity will be launched, at the end, using startForeground (), the service is transferred to the foreground status.

Administrator rights

Another option is to give the application administrator rights. Such rights provide the ability to manage the policy of generating passwords for the lock screen, to remotely lock and wipe the device.

At one time, Google introduced the concept of "device administrator" for companies that would like to manage their employees' smartphones. That is, the company creates an application that gets administrator rights and can lock or reset the phone after a command from the server. That is why an application with administrator rights does not go into Standby mode, because a command to block can come at any time.

Getting, or rather requesting administrator rights, is again easy. First, we need a couple of callbacks that will be called after the rights have been acquired or revoked:

Continuation is available only to members

Option 1. Join the "site" community to read all the materials on the site

Membership in the community during the specified period will open you access to ALL Hacker's materials, increase your personal cumulative discount and allow you to accumulate a professional Xakep Score!

In most smartphones and tablets running Android, the screen turns off after 30 seconds and the device goes into sleep mode if the user has not performed any actions with the device during this time. This setting is set by the manufacturers by default in order to save battery power. the most power-hungry element in a gadget is the screen on.

When is auto-off screen undesirable

However, a situation often arises when this option becomes annoying. For example, when reading slowly from the screen, without scrolling, it can go out after half a minute and you have to press the power button, unlock the device and look for the necessary fragment to continue. Also, the timeout can interfere in the following cases:

  • viewing photos and videos;
  • games in which a break in the user's actions can take a long time (for example, chess);
  • work with navigation maps when GPS positioning is on.

Timeout (English timeout) - a break in any action, activity. Time - time, out - absence, cessation, inactivity. Used to indicate a break for a specific time.

In some programs, the developers provide a function for blocking the system timeout (video players, games), but not in all. Let's figure out how to make sure that the screen in Android does not turn off and the device does not go into sleep mode.

Setting hibernation using native Android tools

You can adjust the time after which Android turns off the screen and goes into sleep mode due to user inactivity in system settings. To do this, you need to go to the settings of your smartphone or tablet, although more correctly it should sound like "go to Android settings" and select the section " Screen", Where in the subsection" Sleep mode»Set the required time or disable this option altogether, if the option to disable it is provided by the device manufacturer.

The screenshots show the timeout settings for the Huawei MediaPad T3 8 tablet, in which there is no option to disable sleep mode. In other gadgets, this may be the item " Never" or " Disable hibernation».

This is the easiest way, but far from the most rational, because in this case, the timeout is set for all installed applications. If we need to set its own waiting time for each program or completely disable the transition to sleep mode while a particular application is running, then we will have to use special utilities.

Configuring screen off by third-party means

A large number of Android sleep management apps can be found on Google Play. Let's consider the most popular ones.

Everlasting screen

A small and lightweight application called " Everlasting screen"Disables sleep mode and does not allow the screen to go out while preselected applications are running.

Working with the utility is extremely simple - just launch it and mark those applications for which the screen will be always on.

The utility correctly detects the software installed on the smartphone / tablet, is free and intuitive.

An interesting application that uses the front camera so that the screen does not turn off while the user is looking at it. The camera controlled by Hold Screen On Demo monitors the user's eyes and as soon as he stops looking at the screen, the utility turns it off.

Hold Screen On Demo has the ability to configure a list of specific applications, during which the camera will track the user's gaze and turn off the screen if the user is away. The app is free and no ads

If these utilities do not suit you, then in the Google Play section “ Similar»You can always find alternatives to the above tools

By default, sleep mode, that is, the screen turns off when inactive on an Android smartphone, occurs after 30 or 60 seconds. This is usually more than enough for most users, and turning off the display saves battery power. However, sometimes this time is not enough, so it is necessary to increase the time before entering sleep mode. How to do it? Now you will find out everything.

Turn off screen sleep up to 30 minutes

On most Android smartphones, the maximum idle time after which the screen turns off is 30 minutes. If these numbers are enough for you, you just need to change the settings.

Go to the section with settings.

Open the "Screen" section.

Find the line "Hibernation", tap on it.

Select the maximum length of time that the user is inactive before the screen goes to sleep.

All. If necessary, the time can be changed at any time.

How do I turn off sleep mode completely (more than 30 minutes)?

If the time to turn off the screen with no activity is more than 30 minutes, you will have to install a third-party application.

Open the Play Market.

You write in search screen alive, click on the search button.

Choose an application, read reviews, install.

Take Active Mobile Applications 'Fading Screen' for example.

Install, run. Select the application for which the screen should not go out, tap on it and see the corresponding icon.

This application should not turn off the screen when the user is inactive at all. Other similar applications work in approximately the same way, which you can also install from the Play Market.

On many Android smartphones and tablets, the screen turns off after 30 seconds of user inactivity. As a rule, this is the best option, in which you can comfortably use the device and economically consume its battery. But there are times when you need to disable hibernation when an application is running. Since it is impossible to do this using standard Android tools, we will tell you how to implement it in other ways.
To begin with, let's define why we might need to disable the screen timeout, because excess screen time leads to a fast battery drain? For example, you are reading an article in a browser or watching a video on YouTube, pause and after a minute your device is already sound asleep. Or another option - you use your smartphone as a remote control or show slides. Thus, the most common cases where a permanently active screen is required are:

  • reading e-books, documents, other text information;
  • viewing photo and video materials;
  • demonstration of something on a smartphone screen;
  • games, the gameplay of which does not require active actions;
  • work with GPS and cartographic programs.
Some programs and games do an excellent job on their own. Usually, in many readers, video players and other applications in the settings there is an option that prevents the device from falling asleep. But not in all. In such cases, the easiest way is to set a longer screen timeout for the active mode in the system settings. But, you must admit, this is not so much inconvenient as it is irrational. Therefore, we will do it differently and will use third-party tools to fine-tune the lock screen.

Method 1. Xposed module

This method requires a dedicated runtime on the device and installed. The module that we need to connect to the Xposed Framework is called Stay Awake - Keep On Screen... It allows you to easily disable the screen lock on certain apps and revert to previous screen timeout settings.

How to download and install Stay Awake - Keep On Screen:

  1. Run the application and select the "Download" section.
  • Use search to find the Stay Awake - Keep On Screen module.

  • On the module page, go to the Versions tab and download its latest version.
  • Install the module and reboot the device.
  • Launch Xposed Installer again and go to the Modules section. Make sure you activate the module by checking the box next to Stay Awake - Keep On Screen.

  • Reboot your device.
  • After all these steps, you can use the function to enable / disable hibernation at the system level for each application. It works very simply. To prevent the screen from turning off, simply hold down both volume buttons in any active application. You will see the inscription “Stay Awake Enable” - this means that the screen in the current application will be on all the time.



    The use of this module is convenient in that it remembers in which applications you turned off the screen timeout, and you can return everything back at any time by simply pressing the volume buttons. This function works even at the level of the native launcher.

    Method 2. Applications

    This application in the Russian-language Google Play is known as the "Everlasting Screen". A small utility with a nice design has one single function - to prevent the device from going into sleep mode when the selected applications are running. To activate it, simply launch Keep Screen On and check the required applications, during which you want to keep the screen on at all times.





    Stay Alive! has several modes of operation:

    • active mode while charging the device;
    • active mode during charging and when operating on battery power;
    • pause mode (inactive mode);
    • automatic mode with rules for selected applications.
    They are switched using a small panel, which is hidden behind a curtain.

    We have to admit, Stay Alive! fulfills its main task at 5+. The application not only prevents the device from going into sleep mode, but offers individual settings for different conditions. For example, you can prevent the screen from turning off when charging, when connected to a car dock, or completely disable the screen timeout altogether. Beyond that, Stay Alive! can pause when the battery charge reaches a specified percentage.

    Additional features include a very useful "Allow the screen to dim" option that allows you to dim the screen, but not turn it off completely.


    The only drawback to Stay Alive! Are paid features, the most important of which is application startup. So, if you are using the free version, you will have to manually launch the utility every time you turn on / restart the device.

    How do you set the screen timeout of your mobile device? And have you ever had to prevent the screen from turning off in certain programs?

    We recommend reading

    Up