L
L
Lisio2014-10-14 13:42:37
Android
Lisio, 2014-10-14 13:42:37

How to keep mobile internet on when screen is off in android?

When the screen is turned off on stock Android 4.2.2 on the Jiayu G4C, the network turns off after a while, and synchronization stops working, including in mail clients, and they cannot raise connections on their own.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Elena, 2014-10-14
@Nidora

Vryatli there is such a possibility. Alternatively, make only the screen fade, but not turn off, and then the Internet will always be on.

P
Puma Thailand, 2014-10-15
@opium

It seems that it was in the network settings to turn it off when the screen went out or not, something like economical modes of operation and so on.

A
Alexander, 2014-10-23
@DrZ0idberg

If we are talking about Wi-Fi, then in the advanced settings you can select the disable mode. Data transfer via the mobile network does not seem to be interrupted due to the screen turning off. If it is interrupted, then this is the crookedness of the firmware (which, in general, is not surprising for the Chinese).
If we are talking about software blocking of a shutdown, then this is done like this:

WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE);
wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, "Lock_TAG");
wifiLock.setReferenceCounted(false);
wifiLock.acquire();
...
wifiLock.release();

In addition, if the application performs some tasks in the background (even those not related to the network), you need to block the processor from falling asleep:
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
cpuLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Lock_TAG");
cpuLock.setReferenceCounted(false);
cpuLock.acquire();
...
cpuLock.release();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question