Cosc 4735 LocationAware API. Previous on … Before we looked at GPS location. – d-gpslocation.pptx

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
Cosc 5/4730 Android Maps v2. Maps V1 and V2 In March 2013 google removed the ability to get a map key for version 1. Version 2 had been introduced in.
Location based services
Cosc 5/4730 Android Services. What is a service? From android developer web pages: Most confusion about the Service class actually revolves around what.
Pete Houston Maintenance, Improvement, Patch, Optimization, Errors, Bugs, …. oh I’m totally FUCKED UP! Coders tend to make many.
Cosc 4/5730 Android and Blackberry Near Field Communications (NFC)
CS378 - Mobile Computing Maps. Using Google Maps Like other web services requires an API key from Google ons/google-apis/mapkey.html.
Location & Maps.  Mobile applications can benefit from being location-aware, e.g.,  Routing from a current to a desired location  Searching for stores.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
Location Aware Devices  Location information can lead to creative applications  GPS hardware  cell tower positioning.
Android wifi-based localization. Localization types Android allows (location providers) – GPS (GPS_PROVIDER) – Cell tower + wifi (NETWORK_PROVIDER) You.
Location and Maps Content Getting Location Getting Google Map In application Test on Emulator/Device.
Programming Part 1 Armond R. Smith Zhenying Wu. Overview of this Class ● Transition from FTC -> FRC ● Using Your Resources ● Java Keywords o Data Types.
Android Development (Basics)
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 Maps. Using Google Maps Content on using Google Maps inside your app Alternatives: Open Street Maps –
Map Applications.
Cosc 5/4730 Sign, convert, and install Android files on Blackberry Playbook.
Cosc 5/4730 A little on threads and Messages: Handler class.
Location Services: Part 1 (Location and Geocoding)
Location based services Using Google Maps v2 etc. in Android apps 1Location based services.
Location based services
CSS216 MOBILE PROGRAMMING Android, Chapter 8 Book: “Professional Android™ 2 Application Development” by Reto Meier, 2010 by: Andrey Bogdanchikov (
1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.
Android Accessing GPS Ken Nguyen Clayton State University 2012.
GEOREMINDERS ANDROID APPLICATION BY: ADRIENNE KECK.
Tracking Tasks and Processes. GET_TASK Make a new app, WatchProcesses – Add permission GET_TASK This permission allows the app to collect lots of information.
Programming Games Reprise: storage, datatypes. Geolocation/Google API example. Work session Homework: [Catch up. Upload work. Post proposal.] Work on your.
Cosc 5/4730 Android Communications Intents, callbacks, and setters.
MAKANI ANDROID APPLICATION Prepared by: Asma’ Hamayel Alaa Shaheen.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
Cosc 4730 Android Fragments. Fragments You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own.
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.
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming – Home and reload buttons for the webbrowser, Applets.
Android - Location Based Services. Google Play services facilitates adding location awareness to your app with automated location tracking Geo fencing.
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming –TextField Action Listeners, JEditorPane action listeners, HTML in a JEditorPane,
Sensors – Part 2 SE 395/595. Location in Android LocationManager class – Configure providers and their listeners LocationListener class – Handles update.
Cosc 5/4735 Voice Actions Voice Interactions (API 23+)
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.
Phonegap Bridge –Geolocation and Google maps CIS 136 Building Mobile Apps 1.
/16 Final Project Report By Facializer Team Final Project Report Eagle, Leo, Bessie, Five, Evan Dan, Kyle, Ben, Caleb.
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)
CS371m - Mobile Computing Maps. Using Google Maps Content on using Google Maps inside your app Alternatives Exist: – Open Street Maps –
USING ANDROID WITH THE INTERNET. Slide 2 Lecture Summary Getting network permissions Working with the HTTP protocol Sending HTTP requests Getting results.
CS378 - Mobile Computing Location (Location, Location, Location)
1. 2 Android location services Determining a device’s current location Tracking device movements Proximity alerts.
CS499 – Mobile Application Development Fall 2013 Location & Maps.
Lecture 5: Location Topics: Google Play Services, Location API
Location Services: Part 1 (Location and Geocoding)
Google VR (gvr) CardBoard and DayDream With OpenGL
Android Application -Architecture.
Android Application Maps 1.
Lecture 5: Location Topics: Google Play Services, Location API.
Android Location Based Services
Android 20: Location Kirk Scott.
Sensors, maps and fragments:
The GoogleMap API By Cody Littley.
Firebase Cloud messaging A primer
CIS 470 Mobile App Development
Geolocation using Google maps
CIS 470 Mobile App Development
Lecture 5: Location Topics: Google Play Services, Location API.
Threads, Handlers, and AsyncTasks
Mobile Programming Dr. Mohsin Ali Memon.
Maps, Geocoding, and Location-Based Services.
Geolocation using Google maps
Presentation transcript:

Cosc 4735 LocationAware API

Previous on … Before we looked at GPS location. – d-gpslocation.pptx d-gpslocation.pptx – While this works, it’s actually not the “Google/ android” recommended method. “If you are currently using the Android framework location APIs, you are strongly encouraged to switch to the Google Play services location APIs as soon as possible.” --Android Developer site.

Google Play services location APIs Provides – GPS, cell tower, and Wifi aggregated information as single “device” Based on permissions. – the current location, get periodic location updates, look up addresses, and geofences. – Note, Geofences is not covered here Possible student project.

Permissions. No API is needed for this example. The permissions you ask for, will determine the accuracy. – So – If you ask for only coarse location, then it will not be as accurate. – And don’t forget for API 23+, you need to ask code to ask for the permissions from the user as well.

Compile Need to add app module file a compile directive In the dependencies section add compile 'com.google.android.gms:play-services- location:8.4.0' – Where was the current version You could have also done compile 'com.google.android.gms:play-services:8.4.0‘ Which brings in all the play services and possible leads to a larger side binary.

Setup GoogleApiClient We need the Location Services API, so mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(LocationServices.API).build(); And we need the three methods that were implemented Implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener – public void onConnectionSuspended(int i) – public void onConnectionFailed(ConnectionResult connectionResult) – public void onConnected(Bundle bundle)

Setup GoogleApiClient (2) In OnStart() – We connect – mGoogleApiClient.connect(); In OnStop() – We disconnect – mGoogleApiClient.disconnect(); Use mGoogleApiClient.isConnected() to check and make sure it is connected.

Last Location Getting last location is very easy Location mLastLocation mLastLocation = LocationServices.FusedLocationApi.getLastLoc ation(mGoogleApiClient); – Location object provides getLatitude(), getLongitude(), getAltitude(), getSpeed(), etc. Also boolean hasAltitude(), hasSpeed(), etc – ation.html ation.html

Location Updates Create a Location Request – We need to define the update interval and “fastest update interval” in milliseconds, plus priority Priority: PRIORITY_BALANCED_POWER_ACCURACY, PRIORITY_HIGH_ACCURACY, PRIORITY_LOW_POWER, or PRIORITY_NO_POWER Example: LocationRequest mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(10000); //10 seconds mLocationRequest.setFastestInterval(5000); //5 seconds mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ ACCURACY); //use GPS location.

Now make the request The request takes a LocationListener – With a onLocationChanged(Location location) method LocationServices.FusedLocationApi.requestLocati onUpdates( mGoogleApiClient, mLocationRequest, this); Where this is the Locationlistener. – Note that if this fails (for any reason), the response goes to the onConnectionFailed method of the GoogleAPIClient listener.

Addresses So be Human readable, we need to convert from a Latitude/longitude location to an address Using the Geocoder class – Reverse geocoding: geographic coordinates to address – Geocoding: address to geographic coordinates – This process can take a little time and should not be done on the UI thread. In the example code, it uses an intent service For display here, I’m just showing how to get the address.

Setup geocoder Geocoder geocoder = new Geocoder(Context, Locale.getDefault()); – We want locale information for how numbers, dates are represented. We can ask for the address based on the Lat/Long and it will return a list of addresses We can specify how many, in our case 1 is fine. List addresses = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 1); – It must be in a try catch to deal with errors of ioException where the service is no available and IllegalArgumentException where Lat or Long is invalid.

Address Now that we have a response, – If the addresses variable is not null then we have at least 1 address in the List – Address mAddress = addresses.get(0); There maybe a lot of information associated with it. – We are interested in the getAddressLine(int index), where we are pulling the address together. ArrayList addressFragments = new ArrayList (); for(int i = 0; i < mAddress.getMaxAddressLineIndex(); i++) addressFragments.add(mAddress.getAddressLine(i)); String FullAddress = TextUtils.join(System.getProperty("line.separator"), addressFragments));

Result

References n/index.html n/index.html

Q A &