javaandroidwifi

Android WiFi Access Point Available Event


I am trying to develop an application that connects some spesific wifi access points if it is available. I wroto a service that loops with 30 seconds interval and looks if these spesific wifi access points are available. I am concerning that it may consume the resources too much. I am thinking of a solution if there is any probability android WifiManager (or another utility) notifies my service about new wifi access points are available. It is like new wifi access point listener.

Is there any utility in android to achive this goal?


Solution

  • You should bear this in mind that your android device regularly scans for WiFi networks when the WiFi radio is on. So you need not check for them manually. It will double the load on the OS.

    You can set a listener for SCAN_RESULTS_AVAILABLE_ACTION within your service. It will notify you when the device finishes its regular scanning process. When you receive this broadcast, check all the access points to see whether your desired access point is available or not. However, you can only do this while your WiFi is ON. But its better to keep WiFi ON rather than continuously toggling it ON and OFF, especially when you do it at a small time interval of just 30 seconds, which would drain the battery much faster.