2

Is it possible to dedicate a WiFi network (to a device with no internet access) to a socket in an app and keep Cellular network as the default internet connection for the Android device (and other network requests from the app)? (Android 5 & 6)

I can easily switch between WiFi and Cellular within the app but the main issue is when WiFi is up, Internet is not accessible anymore for the app and all apps already running on the device (i.e. streaming music, web browser, ...)

I have tried to bind the Wifi network to the process or a socket but I can't find any way to do that with getting the network active (and at this point Android just try to route all the internet traffic to the device...).

My understanding is that Android 5 & 6 provides more flexibility to route traffic to multiple networks at the same time but I think I'm missing something here...

Godix
  • 21
  • 3
  • were you able to find a proper solution for your case? I'm facing the very same problem: https://stackoverflow.com/questions/70455485/how-to-control-simultaneous-stable-traffic-for-any-consumers-maps-auth-ffmpe I see my device is constantly being sticked to a single network and if it's Cellular - it has no idea how to redirect all 10.XX.XX.XX traffic to my Wifi device that has its own http server ready for it. VPNService? Sockets? Third party libraries? – punov Jan 13 '22 at 14:26

1 Answers1

1

As per the Connecting your App to a Wi-Fi Device blog post:

Alternatively, if you’d like to route some of your app traffic to the Wi-Fi device and some to the Internet over the mobile network:

Community
  • 1
  • 1
ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • I already know these docs but I think I'm doing something wrong at some point and not able to solve some issues: 1 - If I add the network manually, the phone connects and: - Opens a popup if Smart Switch is active. I can force the network here (or it disconnect the network) - Connect to the network but at that point no application is able to use the Cellular network 2 - Tried to programmatically add/remove the network but : - I still have Smart Network popup as soon as I enable the Network - I don't like to idea to create and remove the network within the app – Godix Jan 20 '17 at 04:07
  • I think you should really read the whole blog post since it talks about getting the list of already configured networks or adding it programmatically that is entirely independent from Smart Switch. – ianhanniballake Jan 20 '17 at 04:20
  • As soon as you call addnetwork(networkId, true), even before you call wifimamager.reconnect(), the phone switch to WiFi and disable CELLULAR for the other apps like Chrome. If the network remains configured on the phone and WiFi is active, the phone connects to this network and blocks any access to internet through CELLULAR... Seems to be specific to Marshmallow (or Samsung), it works better on another phone (KYOCERA with LOLLIPOP). – Godix Jan 20 '17 at 04:44