title: Use cellular data while connected to Wi-Fi with no internet
body: <p>I'm creating an Android app that connects to another device via WiFi that sends and receives data through a socket connection. I want to be able to use my cellular data to do other things (such as browsing) while staying connected to this device. </p>
  
  <p>On an iOS device, changing the network settings to Static and leaving the Router field blank seems to work. But on my Android device (Samsung Galaxy Note 5 running Android 7.0), it won't let me save the network settings if I leave it blank. </p>
  
  <p>I have tried using 3rd party apps like Mobiwol, Super Download, and Speedify (Only Speedify seemed to work), but I want to be able to do this without the need of these apps. </p>
  
  <p>I have also tried turning on "Keep Mobile data turned on" in the developer settings, and "Smart Network Switch" which just switches to my cellular data so my app does not work since it is not technically connected to the WiFi.</p>
  
  <p><strong>UPDATE: I managed to get cellular to work while connected through WiFi within my app (Thanks to Remy Lebeau and <a href="https://stackoverflow.com/questions/29835240/how-to-stay-connected-through-mobile-network-after-wifi-is-connected-on-android">How to stay connected through mobile network after WIFI is connected on Android?</a>). See code below.</strong></p>
  
  <p><em>Now I would like to be able to use cellular data also in background apps such as notifications or if I'd like to open up a browser etc. Is there a way to do this?</em></p>
  
  <pre><code>NetworkRequest.Builder req = new NetworkRequest.Builder();
  req.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR); 
  req.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); 
  
  ConnectivityManager.NetworkCallback networkCallback = new 
  ConnectivityManager.NetworkCallback() {
  
       @Override
       public void onAvailable(Network network) {
              connectivityManager.bindProcessToNetwork(network)                   
       }
  };
  
  connectivityManager.requestNetwork(req.build(), networkCallback);
  </code></pre>