1 / 6

Android wifi-based localization

Android wifi-based localization. Localization types. Android allows (location providers) GPS ( GPS_PROVIDER) Cell tower + wifi ( NETWORK_PROVIDER) You cannot request only wifi, just wifi and tower. You cannot tell the difference between wifi and tower

keithc
Download Presentation

Android wifi-based localization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Android wifi-based localization

  2. Localization types • Android allows (location providers) • GPS (GPS_PROVIDER) • Cell tower + wifi (NETWORK_PROVIDER) • You cannot request only wifi, just wifi and tower. • You cannot tell the difference between wifi and tower • Except that the accuracy of the tower is 100s of meters, and accuracy of wifi is 10s of meters • You can get tower only by turning off wifi

  3. Make new app • New app called androidLocalization • Add permissions • Internet • Fine location • Course location • Add TextView to UI. Set ID to androidLocalizationTextView • In AndroidLocalizationActivity, add member variable • TextViewandroidLocalizationTextView= null; • In onCreate • androidLocalizationTextView = (TextView)findViewById(R.id. androidLocalizationTextView);

  4. Getting periodic location updates • Add top of class, add member variable • LocationManagerlocationManager = null; • In onCreate, add • locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); • To start wifi+cell tower locallocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); • ization, add • The 3rd argument is the minimum time between updates (so, updates should not arrive any faster than this minimum) • The 4th argument is the minimum distance traveled between updates (so updates should not occur unless the phones has moved this distance) • These arguments are only suggestions. The system might respond faster or slower • If GPS and wifi+cell tower is needed, then two function calls are used • locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); • locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); • Note: passive localization is also possible. In this case, the app does not start wifi or gps. But if some other app does, and gets location info, then this app will get the location info too • locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, locationListener); • When done getting location information, you must unregister with • locationManager.removeUpdates(locationListener); • Note, this unregister will unregister everything

  5. locationListener • LocationListenerlocationListener = new LocationListener() { • @Override • public void onLocationChanged(Location location) { • String str = new String(); • str += "Longitude: "+location.getLongitude()+" latitude: "+location.getLatitude(); • str += " altitude: " +location.getAltitude(); • if (location.hasAccuracy()) • str += " accuracy: "+location.getAccuracy(); • else • str += " accuracy is unknown "; • if (location.hasSpeed()) • str += " speed: "+location.getSpeed(); • else • str += "speed is unknown"; • if (location.hasBearing()) • str += "bearing: "+location.getBearing(); • else • str += "bearing is unknown"; • str += "provider: "+location.getProvider(); • Log.e("locationInfo",str); • androidLocalizationTextView.setText(str); // this works. It seems to come on the UI thread. But maybe it would be safer to make a runOnUiThread function • } • };

  6. Walk around and try android • Compare android to skyhook and to gps • Other things related to localization that are covered in other lectures • Roll-your-own wifi-based localization • Smoothing localization information (Kalman filter)

More Related