Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting an Android app to a wifi without internet access

I have an expo app that works as a companion app to an IoT device.

To connect the device to the wifi, the app has to connect to the device's wifi and send it a network call containing the wifi info.

Up until Android 9, this worked fine. But as I started testing on newer devices, I discovered this doesn't work as smoothly as before, as now if you connect to a wifi without internet access, you get a message saying "This network has no internet access. Stay connected?". The user now has to ideally select "Dont ask again" AND select "Yes" before the network call is sent to the device.

It kinda sucks UX wise as if the user misses this popup, or dismisses it, the network request won't go through as Android blocks all data transfers until you specifically select "Yes" to the popup. If the user misses the popup, they can still see a notification with "This wifi has no internet access" to access the popup.

So, the question is : Is there a way to bypass this? Ideally something like a permission that I can ask the user before hand? I haven't found anything so far except for this issue Force Android to Use Wifi network with no internet that is similar, but in my case the phone doesn't go back to the mobile data, it just doesn't transfer any data between the wifi and the app. Works fine with iOS though :/

like image 869
Matija Martic Avatar asked Sep 24 '19 18:09

Matija Martic


People also ask

Can you use an app without internet?

Native mobile apps act as the interface between the user and the users' data and require uninterrupted connectivity. Native mobile apps with offline capability stores both the mobile app's software and its data locally on the mobile device. Offline mobile apps allow the user to run the app, regardless of connectivity.


1 Answers

Not a solution, but we are experiencing the exact same issue. Up until Android 9, our application was able to connect to a WIFI network without internet and pass traffic. As of 9, we are able to connect to the wifi network without internet, but all traffic is sent via mobile data.

When we manually connect an android 9 device to a WIFI network without internet, we are presented with a popup notification: Internet may not be available. There are two choices - 1) Switch to mobile data or 2) Another network. If we select either option, we are disconnected from the wifi network without internet. If we do nothing (select neither option) and let the pop up disappear after 10 seconds, we remain connected to the wifi network without internet.

When we connect from within our application, no popups are presented to the user and the behavior is as if we had selected the "Switch to mobile data" option.

Would be nice if the android team didn't assume that internet was needed or desired in every situation. Sometimes, we want to connect to networks without internet access and stay connected.

One potential solution is to disable mobile data. While this works, it doesn't appear that that is allowed pro grammatically. In our case, this would require users to enable/disable mobile data in the settings multiple times a day. Right now, our application fetches data from various non-internet wifi networks and then disconnects from the wifi networks to send that data over the internet to a cloud server.

Any ideas on how to resolve in latest version of Android?

like image 118
chaxz Avatar answered Oct 16 '22 08:10

chaxz