title: Android use of mobile data when in background
body: <p>I have developed a hybrid app running on Android, that successfully monitors the users location and displays it to the user as a moving icon on a map. This part of the app is all written in javascript and works inside a webview. The webview also communicates with my remote server to share the user's location with other users of the same app.</p>
  
  <p>Up until Android Nougat this all works even when the app is backgrounded for several days. When the user returns to the app they can see where they have been with timestamps at each point. And all the other app users can see where everyone is, even if they are no actively using the app.</p>
  
  <p>From Android Oreo onwards, I had to move the location tracking to a background service to get it to continue in the background and I have tested this to be still working fine even with the app in the background for a long period. Returning to the app, the user can still see where they have been. However the remote communications to the server, on Android Oreo and later, cease after approximately 2 minutes in the background.</p>
  
  <p>Please could someone explain why this is, and what I could (if anything) do about it?</p>
  
  <p>What is the restriction that I am running into and where is it documented on Android developer? I have set the app as not to be limited in settings/network/data saver and this makes no difference.</p>
  
  <p>Would it make a difference if I replaced the webview XMLHttpRequest with similar code in background service, using volley or something similar?</p>
  
  <p>All help very much appreciated.</p>