Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to...

22
Context Aware Location Nasrullah

Transcript of Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to...

Page 1: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Context Aware Location

Nasrullah

Page 2: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Location Basics

• LocationManager—Class providing access to Android system location services

• LocationListener—Interface for receiving notifications from the LocationManager when the location has changed

• Location—Class representing a geographic location determined at a particular time

Page 3: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

LocationManager (step 1)

• 1)LocationManager needs– to be initialized with Android System Location Service

This provides the application with the device’s current location,movement and can also alert when the device enters or leaves a defined area.

An example of initialization is LocationManager mLocationManager;mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

Page 4: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Location Manager(step 2)

• Location Provider needs to be Selected– Wifi– Gps

• Before that select the criteria for the provider

To find a proper location provider is to define the accuracy and power requirement. This enables the Android system to find the best available location technology for the specified requirements

Page 5: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Example step 2Criteria criteria = new Criteria();criteria.setAccuracy(Criteria.ACCURACY_FINE);criteria.setPowerRequirement(Criteria.POWER_LOW);

Step 2(Assign the Provider to the LocationManager Class;

String locationprovider = mLocationManager.getBestProvider(criteria, true);

Page 6: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

LocationProviders

It is also possible to specify the location estimation technology using the location manager’s getProvider() method.

The two most common providers are the satellitebasedGlobal Positioning System (GPS) (specified by

LocationManager.GPS_PROVIDER)and cell-tower identification (specified by

LocationManager.NETWORK_PROVIDER. The former is more accurate, but the latter is useful

when a direct view of the sky is not available such as indoors

Page 7: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Adding Location Awareness

• Save chosen location on tasks• Adding an overlay that shows the device

current location• Using DDMS to mock locations• Displaying the current location co-ordinates

and accuracy• Filtering the Tasks by Location and Proximity

Page 8: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Location Based Services

• Brightkite• Foursquare• Gowolla• Latitude

Page 9: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

User-stories

• Save Address on Task• See Current Location• Show only nearby Tasks

Page 10: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Cast of Characters• MyLocationOverlay – A simple mapoverlay that

show’s the device current location

• LocationManager – A system utility class that can report the device’s current location

• DDMS – Dalvik Debug and Monitoring Server .A suite of tools to debug and control an Android System

Page 11: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Step-one – Saving an Address on Task

Page 12: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

How a SQLiteOpenHelper works

Page 13: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Saving an Address on a Task Steps

Page 14: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Have you used some sort of database migration feature ,such

as Rails ?

Page 15: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Step 2 –Displaying an Address on its Task

Page 16: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Displaying as Address Steps

Page 17: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Step-3 Adding Current Location to the Map

Page 18: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Mocking Location

Page 19: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Providing Mock Location Data

• As you develop your application, you'll certainly need to test how well your model for obtaining user location works. This is most easily done using a real Android-powered device. If, however, you don't have a device, you can still test your location-based features by mocking location data in the Android emulator. There are three different ways to send your application mock location data: using Eclipse, DDMS, or the "geo" command in the emulator console (copied from)

• http://developer.android.com/guide/topics/location/strategies.html

Page 20: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Adding a Location to the map Steps

Page 21: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Step 4-Displaying a Current Location

Page 22: Context Aware Location Nasrullah. Location Basics LocationManager—Class providing access to Android system location services LocationListener—Interface.

Displaying Current Location Steps