Question

There are numerous good answers how to enable hotspot in code on Android devices. However, the WifiManager thinks that Wi-Fi is disabled in that time and therefore this:

mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
receiverWifi = new WifiReceiver();

// Register broadcast receiver 
// Broacast receiver will automatically call when number of wifi connections changed
registerReceiver(receiverWifi, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
mainWifi.startScan();

never calls WifiReceiver::onReceive() (I tested that while hotspot is inactive, the method is called, i.e. the code is working). I'd perhaps consider this as a fact but then I saw this question where the author claims he was able to create two hotspots and they saw each other. Unfortunately, without code. How something like this could have been done?

No correct solution

OTHER TIPS

When a device is a hotspot, it doesn't connect to another hotspot. You either use wifi to connect to a hotspot, or you use it to be a hotspot. When the hotspot is enabled, as you say "wifimanager thinks wifi is disabled", that's because it can't use wifi to connect to another hotspot.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top