Guest User

Untitled

a guest
Jul 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. @Kroll.method
  2. public void getWirelessNetworks(KrollInvocation invocation) {
  3. if (Util.gEmulatorMode == false) {
  4. wifiMgr = (WifiManager) invocation.getTiContext().getActivity().getSystemService(Context.WIFI_SERVICE);
  5. receiver = new WifiReceiver();
  6. invocation.getTiContext().getActivity().registerReceiver(receiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
  7. wifiMgr.startScan();
  8. }
  9. }
  10.  
  11. // @Kroll.
  12. class WifiReceiver extends BroadcastReceiver {
  13. @Override
  14. public void onReceive(Context c, Intent intent) {
  15. if (Util.gEmulatorMode) {
  16. mNetworkList.initializeEmulator();
  17. } else {
  18. mNetworkList.initialize(wifiMgr.getScanResults());
  19. }
  20. JSONArray networksJSON = new JSONArray(mNetworkList.getNetworkList());
  21. // proxy.fireEvent("networksAvailable", networksJSON);
  22. }
  23. }
Add Comment
Please, Sign In to add comment