2

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?

  • What is the Android version for LG phone? It's possible that, it's running on older Android version and their Android framework is not capable of handling this new change ? – Android4Fun Jun 26 '18 at 23:39
  • The Android version is 8.0. I get the feedback that huawai devices with 8.0 have the same problems. It is possible that the framework is not capable to handling this feature. Or there are some software restrictions. – Christian Heinisch Jun 27 '18 at 04:40
  • I got it worked once on Pixel XL, but it keeps failing after. Never work on Samsung either. – Mia Apr 18 '19 at 09:25

0 Answers0