Skip to content Skip to sidebar Skip to footer

How To Turn Off Wifi Hotspot Programmatically In Android 8.0 (oreo) (setwifiapenabled Is Not Support This Version Anymore)

I reference the code to turn on hotspot in Android 8.0, it is work. But I have no idea about how to disable it @RequiresApi(api = Build.VERSION_CODES.O) private void turnOnHotspot(

Solution 1:

In order to disable it, you need to create a global reference for the WifiManager.LocalOnlyHotspotReservation, assign it in the onSatrted() callback and then close it as follows

private WifiManager.LocalOnlyHotspotReservation mReservation;

privatevoidturnOffHotspot() {
 if (mReservation != null) {
  mReservation.close();
 }
}

You may refer to the following link as follows, it worked for me: How to turn on/off wifi hotspot programmatically in Android 8.0 (Oreo)

Post a Comment for "How To Turn Off Wifi Hotspot Programmatically In Android 8.0 (oreo) (setwifiapenabled Is Not Support This Version Anymore)"