android-studiokotlinwifimanagerhotspotssid

how to get SSID and Password for hotspot (kotlin)


I'm trying to create a hotspot using startLocalOnlyHotspot()

my code:

var ssid = "null"
var password = "null"

wifiManager.startLocalOnlyHotspot(object : LocalOnlyHotspotCallback() {
                override fun onStarted(reservation: LocalOnlyHotspotReservation) {
                    super.onStarted(reservation)
                    if(reservation.wifiConfiguration != null) {
                        ssid = reservation.wifiConfiguration!!.SSID
                        password = reservation.wifiConfiguration!!.preSharedKey
                    }

                }

            }, Handler())

I trying to get SSID and password from startLocalOnlyHotspot()

I put default value for them both as "null" as string just to test because I'm using this value to generate QR-code so I need string

and this value never changes however it creates a hotspot

what did I miss??


Solution

  • I'm having the same problem and found some answer in this post: Change WiFi hotspot's SSID and password in Android Oreo 8.x.However it seems that you cannot change the SSID or password with Local Only Hotspot. Hope you find a solution.