CS499 – Mobile Application Development Fall 2013 Location & Maps.

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

Introducing to Location in Android LOCATION IS EVERYTHING Kamil Lelonek Kamil Lelonek
Prepared by: Prepared by: Jameela Rabaya Jameela Rabaya Fatima Darawsha Fatima Darawsha.
Tracking & Login Data persistence User tracking.
CS378 - Mobile Computing Maps. Using Google Maps Like other web services requires an API key from Google ons/google-apis/mapkey.html.
Chapter 11: Discover! Incorporating Google Maps
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Location & Maps.  Mobile applications can benefit from being location-aware, e.g.,  Routing from a current to a desired location  Searching for stores.
Android Application Development. Agenda  Android Business Model  Why Android  Android application market space  Market Segments & Target customers.
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.
Android wifi-based localization. Localization types Android allows (location providers) – GPS (GPS_PROVIDER) – Cell tower + wifi (NETWORK_PROVIDER) You.
Cosc 5/4730 GPS/Location android.location. Simulator notes All the simulators can simulator GPS/location information – Android DDMS commands (geo) to.
CS378 - Mobile Computing Location (Location, Location, Location)
CS378 - Mobile Computing Location.
CS378 - Mobile Computing Maps. Using Google Maps Content on using Google Maps inside your app Alternatives: Open Street Maps –
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.
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
Social network Twitter Hashtag: #m2eu #android Personal Israel Ferrer –
Location based services
CSS216 MOBILE PROGRAMMING Android, Chapter 8 Book: “Professional Android™ 2 Application Development” by Reto Meier, 2010 by: Andrey Bogdanchikov (
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
MAKANI ANDROID APPLICATION Prepared by: Asma’ Hamayel Alaa Shaheen.
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.
Adding Location Nasrullah. Adding Location Adding a Map Activity Obtaining a Map API Debug Key Adding a Map View Finding an Address with Google’s GeoCoder.
Android - Location Based Services. Google Play services facilitates adding location awareness to your app with automated location tracking Geo fencing.
Android Application Lifecycle and Menus
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
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.
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.
Location based services 1. Some location-based services available in Android Geo-coding – Address -> location Reverse geo-coding – Location -> address(es)
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
CS371m - Mobile Computing Maps. Using Google Maps Content on using Google Maps inside your app Alternatives Exist: – Open Street Maps –
3 rd -party APIs Kalin Kadiev Astea Solutions AD.
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.
Lecture 5: Location Topics: Google Play Services, Location API
Android Application Maps 1.
Tracking device movements
Android Application Development 1 6 May 2018
Lecture 5: Location Topics: Google Play Services, Location API.
Activity and Fragment.
AnDroid GoogleMaps API
Designing Apps Using The WebView Control
Android Location Based Services
Sensors, maps and fragments:
Location Service and Sensors
תכנות ב android אליהו חלסצ'י.
CS371m - Mobile Computing Maps.
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Activities and Intents
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.
SE4S701 Mobile Application Development
Activities and Fragments
Mobile Programming Dr. Mohsin Ali Memon.
Presentation transcript:

CS499 – Mobile Application Development Fall 2013 Location & Maps

Location Services Mobile applications can benefit from being location-aware, e.g., – Routing from current to desired location – Searching for store near location Android allows application to determine & manipuate location

Location Represents a position on Earth A location instance consists of: – Latitude, longitude, a UTC timestamp – Optionally, altitude, speed, bearing

LocationProvider Represents sources of location data Actual data may come from – GPS satellites – Cell phone towers – Internet Different LocationProviders will exhibit different tradeoffs between cost, accuracy, availability & timeliness

LocationProvider Types Passive – Returns locations generated by other providers – Requires android.permission.ACCESS_FINE_LOCATION Network – Determines location based on cell tower and WiFi access points – Requires either android.permission.ACCESS_COARSE_LOCATION or android.permission.ACCESS_FINE_LOCATION GPS – Determines location using satellites – Requires android.permission.ACCESS_FINE_LOCATION

LocationManager System service for accessing location data – getSystemService(Context.LOCATION_SERVICE) Enables – Determining the last known user location – Registering for location updates – Registering to receive intents when the device nears a location

LocationListener Defines callback methods that are called when Location or LocatinProvider status changes – void onLocationChanged(Location location) – void onProviderDisabled(String provider) – void onProviderEnabled(String provider) – void onStatusChanged(String provider, int status, Bundle extras)

Obtaining Location Start listening for updates from location providers Maintain a “current best estimate” of location Stop listening for location updates Use best location estimate.

Location App public class LocationActivity extends Activity { private static final long TWO_MIN = 1000 * 60 * 2, MEASURE_TIME = 1000 * 30; private TextView mTextView = null; private Location mBestReading = null; private LocationManager mLocationManager = null; private LocationListener mLocationListener = null; … protected void onDestroy() { mLocationManager.removeUpdates(mLocationListener); super.onDestroy(); } private String getDisplayString(Location location) { return "Accuracy:" + location.getAccuracy() + " Long.:" + location.getLongitude() + " Lat.:" + location.getLatitude() + " Time:" + location.getTime(); }

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mTextView = (TextView) findViewById(R.id.textView1); int mTextViewColor = mTextView.getCurrentTextColor(); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mBestReading = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (null != mBestReading) { mBestReading.setAccuracy(Float.MAX_VALUE); if (System.currentTimeMillis() - mBestReading.getTime() > TWO_MIN) { mTextView.setTextColor(Color.RED); } mTextView.setText(getDisplayString(mBestReading)); mTextView.setTextColor(mTextViewColor); } else { mTextView.setText("No Initial Reading Available"); } // Location Listener (next slide) mLocationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 0, 0, mLocationListener); mLocationManager.requestLocationUpdates(LocationManager.GPS _PROVIDER, 0, 0, mLocationListener); Executors.newScheduledThreadPool(1).schedule(new Runnable() { public void run() { System.out.println("cancelled location updates"); mLocationManager.removeUpdates(mLocationListener); } }, MEASURE_TIME, TimeUnit.MILLISECONDS); }

mLocationListener = new LocationListener() { public synchronized void onLocationChanged(Location location) { if (null == mBestReading || mBestReading.getTime() - System.currentTimeMillis() > TWO_MIN || location.getAccuracy() < mBestReading.getAccuracy()) { mBestReading = location; mTextView.setText(getDisplayString(location)); } public void onStatusChanged(String provider, int status, Bundle extras) {} public void onProviderEnabled(String provider) {} public void onProviderDisabled(String provider) {} };

Determining Best Location Several factors to consider: – Measurement time – Accuracy – Provider type

Battery Saving Tips Location measurement drains the battery – Return updates less frequently – Restrict set of Location providers: Use least accurate (cheapest) provider possible – Always check last known measurement – Remove updates on onPause()

Maps Visual representation of area Going to use Google Maps library Note part of standard Android distribution – Install SDK add-on – build against add-on “Google APIs (Google Inc.)” Permissions: –

Maps Classes MapActivity MapView GeoPoint Overlay ItemizedOverlay

MapView Extends ViewGroup Displays a Map in one of several modes: – Street View – photographs – Satellite View – aerial – Traffic View – real-time traffic superimposed Supports panning and zooming Supports overlay views Requires a Maps API key –

MapActivity Base class for Activities that display MapViews Subclass creates MapView in onCreate() Only one MapActivity is allowed per process public class MapsEarthquakeMapActivity extends MapActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } protected boolean isRouteDisplayed() { return false; } <com.google.android.maps.MapView android:layout_width="fill_parent“ android:layout_height="fill_parent" android:clickable="true“ android:apiKey=”myMapsAPIkey“ />

GeoPoint Represents a location on Earth – Latitude and longitude measured in microdegrees – 1 microdegree == 1 millionth of a degree

Overlay Manages information drawn over a map – e.g. points of interest within a given city MapView maintains a list of overlays – Retrieve via MapView.getOverlays()

ItemizedOverlay subclass of Overlay Manages a list of OverlayItems – OverlayItems have a particular locaiton – Draws a drawable at OverlayItem’s location Keeps track of a focused item