Hacker News new | ask | show | jobs
by mvdtnz 455 days ago
Surely Android exposes an API to connect to the network? Screenshotting a QR code then googling it feels kind of janky. I have devices like robot vacuums that use a local wifi connection to set themselves up, implying that such an API must exist? I don't do mobile development so maybe I'm off base.
2 comments

Yeah, I agree it feels janky.

They could probably use this API: https://developer.android.com/develop/connectivity/wifi/wifi... or https://developer.android.com/reference/android/provider/Set... to skip the step with Google Lens. Showing the QR-Code is still an interesting functionaliy, for the use case if they had a second phone they wanted to connect that doesn't have this app.

Exactly. I initially went with that approach [1], but eventually opted for on-screen QR code scanning. Suggested networks have lower connection priority and don’t always auto-connect. Also, passwords for suggested networks can’t be viewed or shared later, unlike regular WiFi connections. This is inconvenient because I often need to connect my Mac to the same network later.

[1] https://github.com/yilinjuang/wify/commit/7e63f2a9e6759847b4...

That’s exactly the problem. Android’s API for directly connecting to WiFi is limited—it’s mainly designed for connecting to local or temporary networks, like the setup used by robot vacuums. More details explained here https://news.ycombinator.com/item?id=43384614