Jon Doe
Jon Doe

Reputation: 25

How to find SSID and password of the wifi hotpsot in android Oreo and above?

Is it possible to find SSID and password of wifi hotspot network defined in Settings -> Network -> Hotspot & Tethering or Settings -> Portable Hotspot (depending on a device) in android Oreo or above? I need system hotspot so LocalOnlyHotspot is not an option for me. I found the way to achieve this using reflection, but since version 8.0 it does not work. Also, here I found the way to turn on wifi hotspot programmatically How to turn on/off wifi hotspot programmatically in Android 8.0 (Oreo) (Vishal Sharma answer). But I could not find the way to find SSID and password using this method.

Upvotes: 0

Views: 495

Answers (1)

Raouf
Raouf

Reputation: 31

in Xamarin Android Inside the OnStarted method you can get the ssid and the password in this way:

you have to translate this c# code to java and it will work

public override void OnStarted(WifiManager.LocalOnlyHotspotReservation reservation)
    {
        base.OnStarted(reservation);
        Log.Debug("callBack", "Wifi Hotspot is on now");

        //here is your ssid
        var ssid = reservation.WifiConfiguration.Ssid;

        //here is your password
        var password= reservation.WifiConfiguration.PreSharedKey ;

        mainActivity.mReservation = reservation;
    } 

Upvotes: 1

Related Questions