List of usage examples for android.net.wifi WifiManager SCAN_RESULTS_AVAILABLE_ACTION
String SCAN_RESULTS_AVAILABLE_ACTION
To view the source code for android.net.wifi WifiManager SCAN_RESULTS_AVAILABLE_ACTION.
Click Source Link
From source file:net.helff.wificonnector.WifiConnectivityReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log.i(TAG, "action: " + intent.getAction()); if (intent.getAction().equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) { Intent locationIntent = new LocationIntent(); context.sendBroadcast(locationIntent); }/* w w w.j a va 2 s .c om*/ if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { NetworkInfo networkInfo = (NetworkInfo) intent .getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); Log.d(TAG, "got network_state_changed with detailed info: " + networkInfo == null ? "nothing" : networkInfo.getDetailedState().name()); if (networkInfo != null && networkInfo.isConnected() && networkInfo.getType() == ConnectivityManager.TYPE_WIFI) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean autoConnect = prefs.getBoolean("autoConnect", false); Log.d(TAG, "triggering WifiConnectivityService with autoConnect=" + autoConnect); int command = autoConnect ? WifiConnectivityService.COMMAND_AUTO_UNLOCK_CONNECTION : WifiConnectivityService.COMMAND_CHECK_CONNECTION; Intent msgIntent = new Intent(context, WifiConnectivityService.class); msgIntent.putExtra(WifiConnectivityService.INTENT_COMMAND, command); context.startService(msgIntent); } } if (intent.getAction().equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) { Log.d(TAG, "triggering WifiConnectivityService state changed"); Intent msgIntent = new Intent(context, WifiConnectivityService.class); msgIntent.putExtra(WifiConnectivityService.INTENT_COMMAND, WifiConnectivityService.COMMAND_REFRESH_STATUS); context.startService(msgIntent); } }
From source file:ru.glesik.wifireminders.AlarmService.java
@Override public void onCreate() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); scanReceiver = new BroadcastReceiver() { public void onReceive(Context c, Intent i) { // Scan results are available. WifiManager w = (WifiManager) c.getSystemService(Context.WIFI_SERVICE); // Handle scan results. scanResultHandler(w.getScanResults()); }// www. jav a 2s .co m }; registerReceiver(scanReceiver, intentFilter); }
From source file:ru.glesik.wifireminders.AddReminderActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_reminder); // Show the Up button in the action bar. setupActionBar();/*from ww w. j a v a2s . co m*/ // Prepare receiver for AP scan results. IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); scanReceiver = new BroadcastReceiver() { public void onReceive(Context c, Intent i) { // Scan results are available. WifiManager w = (WifiManager) c.getSystemService(Context.WIFI_SERVICE); // Handle scan results. scanResultHandler(w.getScanResults()); } }; registerReceiver(scanReceiver, intentFilter); }
From source file:uk.ac.horizon.ubihelper.service.channel.WifiScannerChannel.java
/** * @param handler/*from www . ja va 2 s . c o m*/ * @param name */ public WifiScannerChannel(Service service, Handler handler, String name) { super(handler, name); wifi = (WifiManager) service.getSystemService(Service.WIFI_SERVICE); this.service = service; if (wifi == null) Log.w(TAG, "No WifiManager"); IntentFilter filter = new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); this.service.registerReceiver(receiver, filter); }
From source file:me.datenknoten.tueroeffner.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit(); }//from w w w . ja va 2 s . c om IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); registerReceiver(new DerivBroadcastReceiver(this, networkSSID), intentFilter); }
From source file:org.wso2.emm.agent.services.DeviceNetworkStatus.java
private DeviceNetworkStatus(final Context context) { this.context = context; wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); receiverWifi = new WifiReceiver(); // Register broadcast receiver // Broacast receiver will automatically call when number of wifi connections changed context.registerReceiver(receiverWifi, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); // start scanning wifi startWifiScan();/*from w ww .j a v a 2s .com*/ info = getNetworkInfo(context); mapper = new ObjectMapper(); }
From source file:com.farproc.wifi.connecter.TestWifiScan.java
@Override public void onResume() { super.onResume(); final IntentFilter filter = new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); registerReceiver(mReceiver, filter); mWifiManager.startScan();/*from w ww .j av a2 s. c o m*/ }
From source file:foam.starwisp.NetworkManager.java
void Start(String ssid, StarwispActivity c, String name, StarwispBuilder b) { Log.i("starwisp", "Network startup!"); m_CallbackName = name;/*from w w w . j ava2 s . c o m*/ m_Context = c; m_Builder = b; if (state == NetworkManager.State.IDLE) { Log.i("starwisp", "State is idle, launching scan"); wifi = (WifiManager) c.getSystemService(Context.WIFI_SERVICE); state = State.SCANNING; SSID = ssid; wifi.startScan(); receiver = new WiFiScanReceiver(SSID, this); c.registerReceiver(receiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); // todo - won't work from inside fragments m_Builder.DialogCallback(m_Context, m_Context.m_Name, m_CallbackName, "\"Scanning\""); } if (state == NetworkManager.State.CONNECTED) { Log.i("starwisp", "State is connected, callback raised"); m_Builder.DialogCallback(m_Context, m_Context.m_Name, m_CallbackName, "\"Connected\""); } }
From source file:org.wahtod.wififixer.ui.LocalNetworksLoader.java
private void registerReceiver() { IntentFilter filter = new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); BroadcastHelper.registerReceiver(getContext(), receiver, filter, false); }
From source file:org.mozilla.mozstumbler.service.stumblerthread.scanners.WifiScanner.java
public void onReceive(Context c, Intent intent) { String action = intent.getAction(); if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) { if (isScanEnabled()) { activatePeriodicScan(ActiveOrPassiveStumbling.ACTIVE_STUMBLING); } else {/* w w w . j a va2 s . com*/ deactivatePeriodicScan(); } } else if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(action)) { final List<ScanResult> scanResultList = getScanResults(); if (scanResultList == null) { return; } final ArrayList<ScanResult> scanResults = new ArrayList<ScanResult>(); for (ScanResult scanResult : scanResultList) { scanResult.BSSID = BSSIDBlockList.canonicalizeBSSID(scanResult.BSSID); if (shouldLog(scanResult)) { // Once we've checked that we want this scan result, we can safely discard // the SSID and capabilities. scanResult.SSID = ""; scanResult.capabilities = ""; scanResults.add(scanResult); } } mVisibleAPs.set(scanResults.size()); reportScanResults(scanResults); } }