get Device List from WifiManager - Android android.net.wifi

Android examples for android.net.wifi:Wifi Property

Description

get Device List from WifiManager

Demo Code

import java.util.ArrayList;
import java.util.List;

import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;

public class Main {

  public static List<ScanResult> getDeviceList(WifiManager mWifiManager) {

    if (!mWifiManager.isWifiEnabled()) {
      mWifiManager.setWifiEnabled(true);
    }/*from  ww  w.  j  a v a  2  s .c  om*/
    List<ScanResult> tempList = new ArrayList<ScanResult>();
    mWifiManager.startScan();
    tempList = mWifiManager.getScanResults();

    return tempList;
  }

}

Related Tutorials