Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

How to scan wifi networks

$
0
0

Hi everyone, im trying to scan al available networks, and with the help of some other post i have the following code:

import java.util.List;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.app.Activity;

Activity act;
Context context;
WifiManager wm;
List<ScanResult> results;
WifiInfo wifiInfo ;

boolean primeraVez = true;

void setup() {

  fullScreen();
  act = this.getActivity();
  context = act.getApplicationContext();
}
void draw() {
  textSize(height/18);


  if (primeraVez) {
    primeraVez = false;
    WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
    wifiManager.startScan();
    List<ScanResult> result = wifiManager.getScanResults();
    println(result);
  }
}

the intention was to print all the available networks but i'm only obtaining an empty array "[]" over the console, what am i doing wrong?

the code may have some useless parts


Viewing all articles
Browse latest Browse all 941

Trending Articles