I wan't to enable the android hotspot automatically. But i get the error
Target SDK: 26
D/WifiManager: LocalOnlyHotspotCallbackProxy: handle message what: 2 msg: { when=-41ms what=2 arg1=3 target=android.net.wifi.WifiManager$LocalOnlyHotspotCallbackProxy$1 }
W/WifiManager: LocalOnlyHotspotCallbackProxy: failed to start. reason: 3
D/ApManager_Oreo: onFailed:
W/WifiManager: done with the callback...
My code is from Stackoverflow How to turn on/off wifi hotspot programmatically in Android 8.0 (Oreo)
@RequiresApi(api = Build.VERSION_CODES.O)
public void turnOnHotspot() {
WifiManager manager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
manager.startLocalOnlyHotspot(new WifiManager.LocalOnlyHotspotCallback() {
@Override
public void onStarted(WifiManager.LocalOnlyHotspotReservation reservation) {
super.onStarted(reservation);
Log.d(TAG, "Wifi Hotspot is on now");
mReservation = reservation;
}
@Override
public void onStopped() {
super.onStopped();
Log.d(TAG, "onStopped: ");
}
@Override
public void onFailed(int reason) {
super.onFailed(reason);
Log.d(TAG, "onFailed: ");
}
}, new Handler());
}
Permissions are granted. I get this error only on LG devices. Samsung and Nokia works fine.
Does anyone have any idea whats going wrong?