Android: Getting to Wifi scan results without consuming additional battery
In previous post , I have shown how we can start the scanning of wifi and receive the results using BroadcastReceiver. The problem with this approach is it consumes battery each time scanning is started. To avoid this there is another way: Listen to scan results initiated by other applications or by OS. You need to add following in manifest. <receiver android:name="com.example.receivers.WifiScanCompleteReceiver" > <intent-filter> <action android:name="android.net.wifi.SCAN_RESULTS" /> </intent-filter> </receiver> Code for WifiScanCompleteReceiver.java is as follows: package com.example.receivers; //imports public class WifiScanCompleteReceiver extends BroadcastReceiver { public WifiScanCompleteReceiver() {} @ Override public void onReceive(Context context, Intent intent) { Log.d(HelperUtils.getInstance().getApplicationName(), "Wifi scan result received."); Vector < String > WifiNames = new Vector ...