Skip to content

Instantly share code, notes, and snippets.

@benwilson512
Created December 17, 2010 20:08
Show Gist options
  • Save benwilson512/745613 to your computer and use it in GitHub Desktop.
Save benwilson512/745613 to your computer and use it in GitHub Desktop.
@Kroll.method
public void getWirelessNetworks(KrollInvocation invocation) {
if (Util.gEmulatorMode == false) {
wifiMgr = (WifiManager) invocation.getTiContext().getActivity().getSystemService(Context.WIFI_SERVICE);
receiver = new WifiReceiver();
invocation.getTiContext().getActivity().registerReceiver(receiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
wifiMgr.startScan();
}
}
// @Kroll.
class WifiReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context c, Intent intent) {
if (Util.gEmulatorMode) {
mNetworkList.initializeEmulator();
} else {
mNetworkList.initialize(wifiMgr.getScanResults());
}
JSONArray networksJSON = new JSONArray(mNetworkList.getNetworkList());
// proxy.fireEvent("networksAvailable", networksJSON);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment