Create a LAN Access Point on Android device (no Internet needed)

Denis Yakovenko picture Denis Yakovenko · Feb 10, 2016 · Viewed 8.1k times · Source

I need to implement the following functionality:

  • The application should programmatically make the Android device a LAN server (i.e. other devices should be able to connect to the network created by the application wirelessly, like connection to the wifi spot, but not to the Internet)

  • The application should be able to register the devices connected to the application's network

  • The application's network should be protected by a password


Is it possible to implement such a functionality? Currently, I've only managed to set up a web server on the device using nanohttpd, but it doesn't seem to be the correct path for doing what I need. I've read some similar questions on SO but either didn't understand the concepts or just couldn't find the appropriate answer.

If it is possible, how should I implement it? Is there anything that I could read about solving a similar problem? Or, maybe, someone has already faced something like that and has some experience with dealing with such a task?

Any help is very appreciated.

Answer

kleric picture kleric · Feb 10, 2016

It sounds like wifi direct is what you're looking for. Using WifiP2PManager.createGroup() will allow a device to act as a wireless router if you will, allowing other devices to connect to it as if they were connecting to wifi.

Be warned you will not be able to connect to the device's wifi signal without the random passphrase generated by the device. You can find the passphrase by calling WifiP2PManager.requestGroupInfo() and passing a GroupInfoListener. Calling getPassphrase() on the WifiP2PGroup.