Android O offers wifiManager.startLocalOnlyHotspot to create a closed network. For designing a shortcut or widge to toggle this kind of hotspot, how could I know the status of LocalOnlyHotspot to judge to start or close it?
And when I start a localOnlyHotspot, how can other device connect to it? (how to get the password of it?)
This code may help you to get it running. I implemented a Hotspotmanager Class, which can be used in applications. After turning on the hotspot, it deliveres a wificonfiguration object to a listener which you have to implement in your calling activity. From this config, you can take the SSID and preSharedKey. NOTE: SSID and Password can't be changed!!! Because the creation is fully hidden in Androids system API.