In my app I programmatically connect to an Access Point that has no access to the internet via WifiManager and WifiConfiguration. Later on I have to access a device connected to it to read data – but I didn't get that far.
After connecting to the Wifi I'm getting my DHCP setup just fine, but if I try to ping the Gateway address by typing:
$ adb shell
OnePlus6:/ $ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
^C
--- 192.168.1.1 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1015ms
The gateway is unreacheable...
I suspect this has to do with the fact that Android (9?) re-routes all traffic in case of a "dead" Wifi over to mobile data – for example you can still browse the internet just fine.
You can easily replicate the issue like this:
- Connect to an Access Point w/o internet access
- Check if your internet still works (e.g. go to google.com)
- Connect you phone via
adband ping the address of your AP
Any ideas on how to force the traffic trough Wifi, even if it's "offline"?
Edit: Output of ip route show:
OnePlus6:/ $ ip route show
10.16.52.64/29 dev rmnet_data0 proto kernel scope link src 10.16.52.67
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.116