Friday, February 9, 2018

Android programmatically connect to a wifi network without Internet

Android doesn't like to connect to wifi without Internet. But what about when you want to use a local wifi connection to quickly move large volumes of data between nearby devices? The secret is that you need to obtain the Network object that corresponds to the wifi, and then use it to open URL connections, create a SocketFactory, or even bind the application. How to find out which object that is? The big (undocumented) secret is that the NetworkInfo's getExtraInfo method will return a string that matches the SSID. With thanks to this blogpost by Nishkarsh Sharma.
With

No comments:

Post a Comment