Created
December 17, 2010 20:08
-
-
Save benwilson512/745613 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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