Search code examples
androidandroid-studioandroid-wifi

How do i connect to LocalOnlyHotspot (Android 8.x+)?


I've been successfully able to make a hotspot using LocalOnlyHotspot. It gives me a hotspot with SSID Android_share_xxxx and unknown password. How do I connect my other devices to this hotspot?


Solution

  • We can get the generated wifi configuration by:

            @Override
        public void onStarted(WifiManager.LocalOnlyHotspotReservation reservation) {
          super.onStarted(reservation);
          hotspotReservation = reservation;
          currentConfig = hotspotReservation.getWifiConfiguration();
    
          Log.v("DANG", "THE PASSWORD IS: "
              + currentConfig.preSharedKey 
              + " \n SSID is : "
              + currentConfig.SSID); 
    
          hotspotDetailsDialog();
    
        }