Use 3G for internet and WiFi for LAN in android - android

I am developing an android app to stream movies from local server on a WiFi. The WiFi does not have internet, it will be used only for accessing the streaming server.
What would make the app kickass is that the app users can continue using internet on their 3G while connected to my WiFi and streaming the movie.
I know for a fact that when android connects to a WIFI, the phone under the hood makes a call to clients.google.com/generate_204 to check if internet is available on the WIFI. If it receives no response, it continues using 3G along with being connected to the WiFi. However, in this scenario if my app makes a request to say 192.168.24.5 (ip address of my streaming server), it does not use WiFi to reach this ip but hunts for this address on 3G and fails.
What i need to achieve is that when android is connected to both my wifi and 3G, any call to private ip is directed to WiFi whereas any call to internet should use 3G.
Can this be done and how?

Related

Android app access local WiFi device with no Internet while phone mobile data is on

I’m working on an Android application that communicates with a Socket to a hardware device that serves a WiFi access point. This WiFi access point does not provide access to the Internet. I’m unable to connect to the socket while Mobile Data on the phone is turned on.
How can I communicate with this device without requiring the user to turn off mobile data? I don’t need to communicate with the Internet over the mobile data connection at the same time as I am communicating with the device over WiFi, but I would like to be able to switch back and forth.
I’ve tried binding the socket to the IP address associated with the network interface connected to the WiFi access point, but that didn’t work.

Bluetooth hotspot and Wifi simultaneously in the same app

Is there a way to create an app for ios/android that can be smart enough to connect to (wifi / cellular) AND a bluetooth hotspot at the same time?
successfully managed to connect to the bluetooth hotspot and access data however when the phone is on bluetooth it cannot access the internet through cell or wifi
Needs to be able to connect to a bluetooth devices hotspot and access its local host aswell as be able to connect to the internet through wifi/cell at the same time
Or if there is a way to tell the app that any request to the IP of the bluetooth device will go via bluetooth and all other requests through wifi
the worst idea so far - alternate connection between wifi and bluetooth so that both never work at the same time. Possible app permissions nightmare
ideas welcome

Accessing Website On Offline Network With Android 11+

I have a webserver that is running on a network that is not connected to the internet.
The webserver serves up a website.
When I connect an android phone to it, I am able to run the website that is on the webserver
But with certain phones that are running Android 11 I need to disable the mobile data on the phone before it will try to access the website over wifi. It seems the phone will not try to request the url on the wifi network because it doesn't have internet, so it defaults to using the 4G/5G Cellular internet connection. This is too bad, because I would like the phone to use the wifi connection.
I would think that perhaops I could "force" the phone to use the wifi connection by typing the IP address in the browser's URL bar (eg. http://192.168.211.1/index.php), however it seems that even with the "local ip" it will still try to use the 4G/5G network instead of the "offline wifi" network.
The only workaround I have found is to disable moblie data on the phone, but this is not ideal.
I would think that some IoT devices would have an offline webserver used for configuation/control.
Is there a certain port or settings I should be using?
Is there a designated port that the browser/OS would expect to be on an offline network?
Basically, how can I make the phone use the wifi, even though the wifi is not connected to the internet?
Thanks so much for any pointers!

Properly route non internet Wifi sockets & Cellular Internet request (Android L & M)

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...
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:
For HTTP requests you can use Network#openConnection(java.net.URL), directly routing your request to this network.
For low-level socket communication, open a socket and call Network#bindSocket(java.net.Socket), or alternatively use Network#getSocketFactory.

Android Mobile-to-Mobile socket connection over public wifi?

I've written an Android app that includes creating a socket connection between 2 mobiles over wifi. The connection works fine at home with my wireless router and WEP security. However, when I tried to run the app at my local coffee shop, I could not make the socket connection. Both droids were connected to the shop's wireless network and the client was using the correct IP address. However, when I tried to make the connection, I received a SocketTimeoutException. I've tried this app at other (home-type with WEP) locations and as long as both mobiles are connected to the wifi network they can set up the socket connection.
Is there something in the configuration of public wifi networks that doesn't allow socket connections to be set up?
It can be that router in this coffe shop allows only specific ports like 80 for http and other ports are blocked by device, maybe you can try setting up your server on the device on such normally open port.

Categories

Resources