25

In "Settings"->"Data Usage" there is a "Restrict background data" checkbox.

How does it work, exactly? What does "background" mean here? And is this setting enforced by the OS, or is it a hint that the apps are free to disregard if coded improperly?

enter image description here

sashoalm
  • 829
  • 2
  • 13
  • 24

1 Answers1

16

First, that setting is enforced by the OS (so it's not for the app to decide whether to observe that setting). Put in easy words: Android won't let an app access the network unless it's running in foreground (i.e. the user is interacting with it) with the restriction enabled for it.

Explained with a plastic example: Restrict background data on the Google Play Store app (as I did), it won't anymore check for updates in background while you are on mobile data. But it will do so when you're using WiFi. Also, when you call up the app to install something, it will work as long as you keep it in foreground (i.e. not switch to another app while it's still downloading).

Izzy
  • 91,166
  • 73
  • 343
  • 943
  • Thanks. So that comment I linked to is wrong? – sashoalm Oct 26 '13 at 22:38
  • I cannot guarantee that, but I would say so. A setting regarding which that would be true is "background sync" (as even the API doc writes "apps should obey", not "apps must obey). THelper might have mistaken that setting, as the names are quite similar. Thanks for the pointer, I will add a comment there for clarification. – Izzy Oct 26 '13 at 22:42
  • 2
    A quick note on what "foreground" means: usually, in Android, an app is in the foreground if any of its activities are the topmost activity on the screen. The NetworkPolicyManager adds an extra constraint that the screen must be on. "The user is interacting with it" suggests that you must be poking the buttons or something, but actually the activity just needs to be visible on the screen with no other app's activities on top of it. – Dan Hulme Oct 26 '13 at 22:51
  • @sashoalm See the answer I posted on the question you linked for why people might get confused about what the setting does. – Dan Hulme Oct 26 '13 at 22:53
  • Does this also disable services like Android Device Manager? – Stephen Angelico Oct 14 '15 at 14:41
  • @StephenAngelico I don't know how exactly this functionality is implemented – but I doubt that. How shall Android determine which service would use this – and even more, make sure that service has no other purpose the user doesn't want to restrict? – Izzy Oct 14 '15 at 15:02
  • Well, I thought the remote lock and erase would have to be a background service. When using Extreme Power Saving mode on my HTC, it says remote locating services will not work. This could understandably be because it suspends a lot of processes, but it also restricts data usage fairly heavily. – Stephen Angelico Oct 14 '15 at 23:34
  • Hey, is there a way to restrict background data in WIFI also? –  Nov 04 '15 at 13:20
  • @SPRajagopal at least not built-in AFAIK. With root powers and 3rd party apps like Greenify, this should be possible. – Izzy Nov 04 '15 at 15:39