title: How to make network calls on Android with an app in the background
body: <p>I am building a react-native app that launches a series of network requests (both UDP, HTTP) when it receives a special kind of notification, or based on a delayed execution.</p>
  
  <p>However it turns out that after the first or second call, it enqueues the calls, without making them. If I open the applications, the remaining network calls are made, and the process continues.</p>
  
  <p>It's a normal issue given that there is a specific doc page inside Android documentation targeting this behaviour:</p>
  
  <ul>
  <li><a href="https://developer.android.com/topic/performance/vitals/bg-wifi" rel="nofollow noreferrer">Excessive Wi-Fi Scanning in the Background</a></li>
  <li><a href="https://developer.android.com/topic/performance/vitals/bg-network-usage" rel="nofollow noreferrer">Background Execution Limits</a></li>
  </ul>
  
  <p>I have read and research over SO: <a href="https://stackoverflow.com/questions/40216992/best-place-to-make-network-calls">Best place to make network calls</a>, <a href="https://stackoverflow.com/questions/49048434/how-to-make-network-call-from-background-service">How to make network call from Background service?</a> but those methods did not work to bypass the obstacle. I can require the user to deactivate "battery optimisation" if required, but that did not work either.</p>
  
  <p>I should mention that I am using React Native in order to handle the lifecycle and trigger the network calls, so they are running inside an Activity that is not in the background or when the phone is locked. I believe there should be ways moving things to a) a background thread or b) an Android service.</p>
  
  <p>I really appreciate any response, experience or links that would help me address this problem.</p>