Android Open Source - nextgislogger Wi Fi Engine






From Project

Back to project page nextgislogger.

License

The source code is released under:

GNU General Public License

If you think the Android project nextgislogger listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/******************************************************************************
 * Project: NextGIS Logger//from w w  w . j  a  v a  2  s. c o  m
 * Purpose: Productive data logger for Android
 * Authors: Stanislav Petriakov
 ******************************************************************************
 * Copyright  2014 NextGIS
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *****************************************************************************/
package com.nextgis.logger;

import java.util.List;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;

public class WiFiEngine {
  private BroadcastReceiver wifiReceiver;
  private Context ctx;
  List<ScanResult> wifis;
  
  public WiFiEngine(final Context ctx) {
    this.ctx = ctx;
    
    wifiReceiver = new BroadcastReceiver() {
      public void onReceive(Context context, Intent intent) {
        wifis = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).getScanResults();
      }
    };
    
    onResume();
  }
  
  public void onResume() {
    IntentFilter intentFilter = new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
    ctx.registerReceiver(wifiReceiver, intentFilter);
  }
  
  public void onPause() {
    ctx.unregisterReceiver(wifiReceiver);
  }
  
  public void scan() {
    ((WifiManager) ctx.getSystemService(Context.WIFI_SERVICE)).startScan();
  }
  
  public String getItem() {
    return wifis.get(0).SSID;  // loop
  }
}




Java Source Code List

com.nextgis.logger.AboutActivity.java
com.nextgis.logger.C.java
com.nextgis.logger.CellEngine.java
com.nextgis.logger.GPSEngine.java
com.nextgis.logger.IntEditTextPreference.java
com.nextgis.logger.LoggerService.java
com.nextgis.logger.MainActivity.java
com.nextgis.logger.MarkActivity.java
com.nextgis.logger.PreferencesActivity.java
com.nextgis.logger.SensorEngine.java
com.nextgis.logger.SessionsActivity.java
com.nextgis.logger.SimpleFileChooser.java
com.nextgis.logger.WiFiEngine.java