Cosc 5/4730 GPS/Location android.location. Simulator notes All the simulators can simulator GPS/location information – Android DDMS commands (geo) to.

Slides:



Advertisements
Similar presentations
Android Application Development Tutorial. Topics Lecture 4 Overview Overview of Sensors Programming Tutorial 1: Tracking location with GPS and Google.
Advertisements

Bruce Scharlau, University of Aberdeen, 2010 Android and Location Mobile Computing Unless otherwise stated, images are from android sdk.
VIP Smartphone Team – Ahmad, Din, Vinayak Car Locator App Fall 2010 VIP Smartphone Team Ahmad, Din, Vinayak.
Introducing to Location in Android LOCATION IS EVERYTHING Kamil Lelonek Kamil Lelonek
Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
HTML 5 – GeoLocation and Maps. Geolocation API What is a ”geolocation”…? A geographical location, defined in terms of – Latitude (north/south) – Longitude.
Location & Maps.  Mobile applications can benefit from being location-aware, e.g.,  Routing from a current to a desired location  Searching for stores.
Location Aware Devices  Location information can lead to creative applications  GPS hardware  cell tower positioning.
Cosc 5/4730 GPS/Location Blackberry JSR-179: javax.microedition.location and android.location.
© 2009 Research In Motion Limited Introduction to GPS and Wi-Fi technology on BlackBerry smartphones.
Android wifi-based localization. Localization types Android allows (location providers) – GPS (GPS_PROVIDER) – Cell tower + wifi (NETWORK_PROVIDER) You.
Position and Motion Section 1.1.
Location and Maps Content Getting Location Getting Google Map In application Test on Emulator/Device.
CS378 - Mobile Computing Location (Location, Location, Location)
CS378 - Mobile Computing Location.
Map Applications.
Android Sensors & Async Callbacks Jules White Bradley Dept. of Electrical and Computer Engineering Virginia Tech
Route Tracker App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Android Location Based Services
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
CS5103 Software Engineering Lecture 08 Android Development II.
Location-Based API 1. 2 Location-Based Services or LBS allow software to obtain the phone's current location. This includes location obtained from the.
Location Services: Part 1 (Location and Geocoding)
Location based services Using Google Maps v2 etc. in Android apps 1Location based services.
Mobile Programming Lecture 9 Bound Service, Location, Sensors, IntentFilter.
1 Localization and Sensing Nilanjan Banerjee Mobile Systems Programming (Acknowledgement: Jules White) University of Arkansas Fayetteville, AR
Location based services
CSS216 MOBILE PROGRAMMING Android, Chapter 8 Book: “Professional Android™ 2 Application Development” by Reto Meier, 2010 by: Andrey Bogdanchikov (
Cosc 5/4730 Android Content Providers and Intents.
Android Accessing GPS Ken Nguyen Clayton State University 2012.
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.
Cosc 5/4730 Android Communications Intents, callbacks, and setters.
MAKANI ANDROID APPLICATION Prepared by: Asma’ Hamayel Alaa Shaheen.
Customizing ArcReader to support GPS Kelly Johnston Indiana Department of Environmental Management.
GPS Provider:  GPS signal Network Location Provider:  Cell ID  Wi-Fi.
Location. GPS Global Positioning System – At least 4 satellites typically used 3 required extra for error detection and altitude typically accurate within.
Maps Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.
LocationListener in Android Nasrullah. The LocationManager provides access to the system location services The LocationListener is used for receiving.
Android - Location Based Services. Google Play services facilitates adding location awareness to your app with automated location tracking Geo fencing.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
LAB 1 Navigation Coordinate System on Earth
Sensors – Part 2 SE 395/595. Location in Android LocationManager class – Configure providers and their listeners LocationListener class – Handles update.
Cosc 4735 LocationAware API. Previous on … Before we looked at GPS location. – d-gpslocation.pptx
Event-driven design will set you free The Observer Pattern 1.
Location Based Services. Android location APIs make it easy for you to build location-aware applications, without needing to focus on the details of the.
Launch your browser (Explorer). Go to Minimize your browser until instructed otherwise.
GPS and MapView. First In the emulator, set the time zone to something (e.g., east coast) and check that the time is correct. Otherwise, the gps emulator.
Lecture 5: Location Topics: Google Play Services, Location API Date: Feb 16, 2016.
Android Fundamentals. What is Android Software stack for mobile devices Software stack for mobile devices SDK provides tools and APIs to develop apps.
CS378 - Mobile Computing Location (Location, Location, Location)
1. 2 Android location services Determining a device’s current location Tracking device movements Proximity alerts.
Location-Based Services. Objectives How to display Google Maps in your application How to control displayed maps How to perform geocoding and reverse.
CS499 – Mobile Application Development Fall 2013 Location & Maps.
Location Services: Part 1 (Location and Geocoding)
Tracking device movements
Lecture 5: Location Topics: Google Play Services, Location API.
Designing Apps Using The WebView Control
Android Location Based Services
Sensors, maps and fragments:
Location Service and Sensors
CIS 470 Mobile App Development
Location (Location, Location, Location)
null, true, and false are also reserved.
Proposed Solution To Parts Of
OO Design with Inheritance
CIS 470 Mobile App Development
Lecture 5: Location Topics: Google Play Services, Location API.
CS378 - Mobile Computing Location and Maps.
Maps, Geocoding, and Location-Based Services.
Presentation transcript:

Cosc 5/4730 GPS/Location android.location

Simulator notes All the simulators can simulator GPS/location information – Android DDMS commands (geo) to the emulator.

Android basics Get a LocationManger from the system Choose a provider with Criteria or just a provider – providers: gps, network, etc… get the Location and use the data. Use a LocationListener

Permissions Add them to the AndroidManifest.xml – Maybe needed for some things, but needed the mapactivity. – GPS location – Cell_ID or WiFI location There maybe other needed as well – ACCESS_LOCATION_EXTRA_COMMANDS, ACCESS_MOCK_LOCATION – See CN/reference/android/Manifest.permission.html for all permissions.

android.location package Address – A class representing an Address, i.e, a set of Strings describing a location. Criteria – A class indicating the application criteria for selecting a location provider. Geocoder – A class for handling geocoding and reverse geocoding. GpsSatellite – This class represents the current state of a GPS satellite. GpsStatus – This class represents the current state of the GPS engine. Location – A class representing a geographic location sensed at a particular time (a "fix"). LocationManager – This class provides access to the system location services. LocationProvider – An abstract superclass for location providers.

android.location package (2) Listeners GpsStatus.Listener – Used for receiving notifications when GPS status has changed. GpsStatus.NmeaListener – Used for receiving NMEA sentences from the GPS. LocationListener – Used for receiving notifications from the LocationManager when the location has changed. A addProximityAlert(double latitude, double longitude, float radius, long expiration, PendingIntent intent) can be added to the LocationManger – Sets a proximity alert for the location given by the position (latitude, longitude) and the given radius.

LocationManager This is the factory class to get location information – You do not instantiate this class directly, retrieve it through Context.getSystemService(Context.LOCATION_SERVIC E) – Now you can get a Location information with getLastKnownLocation(String Provider); – and more information about the provider with LocationProvider getProvider(String name) Providers are found in a couple of ways

Providers List getProviders(Boolean enabledOnly) – get a list of providers, true for ones that are working String getBestProvider(Criteria criteria, boolean enabledOnly) – get a provider based on Criteria List getAllProviders() – Returns a list of all providers – You can use boolean isProvidersEnabled(String) to determine if it is enabled or not.

LocationProvider Information about the Provider int getAccuracy(), int getPowerRequirement(), boolean hasMonetaryCost() boolean meetsCriteria(Criteria criteria) boolean requiresCell() – Returns true if the provider requires access to an appropriate cellular network (e.g., to make use of cell tower IDs), false otherwise. boolean requiresNetwork() – Returns true if the provider requires access to a data network (e.g., the Internet), false otherwise. boolean requiresSatellite() – Returns true if the provider requires access to a satellite-based positioning system (e.g., GPS), false otherwise. boolean supportsAltitude() – Returns true if the provider is able to provide altitude information, false otherwise. boolean supportsBearing() – Returns true if the provider is able to provide bearing information, false otherwise. boolean supportsSpeed() – Returns true if the provider is able to provide speed information, false otherwise.

Criteria UnitsDefault ValueSetterAccessor Horizontal accuracy Meters NO_REQUIREMENT setHorizontalAccura cy getHorizontalAccur acy Vertical accuracyMeters NO_REQUIREMENT setVerticalAccuraygetVerticalAccuracy Preferred response time Milliseconds NO_REQUIREMENT setPreferredRespon seTime getPreferredRespon seTime Power consumption int NO_REQUIREMENT setPreferredPowerC onsumption getPreferredPower Consumption Cost allowedboolean true (allowed to cost) setCostAllowedisAllowedToCost Speed and course required boolean false (not required) setSpeedAndCourse Required getSpeedAndCours eRequired Altitude requiredboolean false (not required) setAltitudeRequiredgetAltitudeRequire d Address requiredboolean false (not required) setAddressInfoRequ ired getAddressInfoRequ ired Note: NO_REQUIREMENT, POWER_USAGE_LOW, POWER_USAGE_MEDIUM, POWER_USAGE_HIGH are field constants

Location Has a standard set of getters you would expect – double getLatitude(), double getLongitude(), float getSpeed(), double getAltitude() – long getTime() Returns the UTC time of this fix, in milliseconds since January 1, – float getAccuracy() Returns the accuracy of the fix in meters. – float getBearing() Returns the direction of travel in degrees East of true North. – Returns true if has X hasAltitude(), hasBearing(), hasSpeed(), hasAccuracy()

Location (2) float bearingTo(Location dest) – Returns the approximate initial bearing in degrees East of true North when traveling along the shortest path between this location and the given location. static void distanceBetween(double startLatitude, double startLongitude, double endLatitude, double endLongitude, float[] results) – Computes the approximate distance in meters between two locations, and optionally the initial and final bearings of the shortest path between them. float distanceTo(Location dest) – Returns the approximate distance in meters between this location and the given location.

Example code get a location LocationManager myL = (LocationManager) getBaseContext().getSystemService(Context.LOCATION_SERVICE); //or use (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); Location loc = myL.getLastKnownLocation("gps"); if (loc != null ) { double sLatitude = loc.getLatitude(); double sLongitude = loc.getLongitude(); String location = sLatitude+","+sLongitude; } else { //No location can be found with gps }

LocationListener Create a LocationListener or implement LocationListener in a class The following methods must be implemented – void onLocationChanged(Location location) Called when the location has changed. – void onProviderDisabled(String provider) Called when the provider is disabled by the user. – void onProviderEnabled(String provider) Called when the provider is enabled by the user. – void onStatusChanged(String provider, int status, Bundle extras) Called when the provider status changes. Status can be OUT_OF_SERVICE, TEMPORARILY_UNAVAILABLE, AVAILABLE

LocationListener added to your LocationManger LocationManager myL = (LocationManager) getBaseContext().getSystemService(Context.LOCATION_SERVICE); myL.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, myLocationListener); – here Use a GPS provider, could be NETWORK_PROVIDER – minTime the minimum time interval for notifications, in milliseconds. This field is only used as a hint to conserve power, and actual time between location updates may be greater or lesser than this value. Here set to 0 – minDistance the minimum distance interval for notifications, in meters. Again set to 0 here. – myLocationListener is a the LocationListener to be called.

Example code A simple android program is provided on the website. It will display location information in a TextView. It also has a LocationListener. Use the ddms.bat in the tools directory to change the location info.

References Android (many links have mapactivity as well, skipped in lecture, we’ll come back to it) – CN/guide/topics/location/index.html – android.html – location- api/ napi – Controlling the android emulator – CN/guide/developing/tools/ddms.html#emulator-control

Q A &