Download presentation
Presentation is loading. Please wait.
1
Location Aware Devices Location information can lead to creative applications GPS hardware cell tower positioning
2
Location Interface Location hardware and J2ME interface Obtaining a location provider Criteria c = new Criteria(); LocationProvider lp = LocationProvider.getInstance(c); Location l = lp.getLocation();
3
Location Interface Location hardware and J2ME interface Obtaining a location provider Criteria c = new Criteria(); LocationProvider lp = LocationProvider.getInstance(c); Location l = lp.getLocation(); Criteria – specify requirements for power consumption accuracy altitude cost allowed (could be null)
4
Selected API Criteria – specify requirements for power consumption accuracy altitude cost allowed boolean isValid() AddressInfo getAddressInfo() AddressInfo is a collection of fields (street, city, zip,...) AddressInfo interface:int getField() void setField(int field, String value) QualifiedCoordinates getQualifiedCoordinates() Qualified Coordinates double getLatitude() [-90; 90] double getLongitude()[-180; 180) float getAltitude() float distance(Coordinate c)geodesic distance to given coordinates
5
Selected API Location boolean isValid() AddressInfo getAddressInfo() AddressInfo is a collection of fields (street, city, zip,...) AddressInfo interface:int getField() void setField(int field, String value) QualifiedCoordinates getQualifiedCoordinates() Qualified Coordinates double getLatitude() [-90; 90] double getLongitude()[-180; 180) float getAltitude() float distance(Coordinate c)geodesic distance to given coordinates
6
Selected API LocationProvider LocationProvider getInstance() Location getLastKnownLocation() void setLocationListener(LocationListener listener, int interval, int timeout, int maxage) the attached listener will be called at the defined interval each update triggered within [interval, interval+timeout] LocationListener interface – must implement the following methods void locationUpdated(LocationProvider provider, Location location) called periodically by the provider with the new location void providerStateChanged(LocationProvider provider, int newState) newState: AVAILABLE, OUT_OF_SERVICE, TEMPORARILY_UNAVAILABLE
7
Sample MIDlet ( From Knudsen ) void run() {// done in separate thread Criteria c = new Criteria(); LocationProvider provider = LocationProvider.getInstance(c); if (provider == null) {... } Location location = provider.getLocation(10); QualifiedCoordinates qc = location.getQualifiedCoordinates(); double lat = qc.getLatitude(); double lon = qc.getLongitude(); LocationListener listener = this; // The MIDlet provider.setLocationListener(listener, 4, 1, 1); } // MIDlet implements LocationListener public void locationUpdated(LocationProvider provider, Location location) { QualifiedCoordinates qc = location.getQualifiedCoordinates(); double lat = qc.getLatitude(); double lon = qc.getLongitude(); }
8
Simulating Device Location WTK makes it possible to predefine a path of travel points XML formatted description <waypoint time="0" latitude="90" longitude="105"/> <waypoint time="10000" latitude="90" longitude="82"/> <waypoint time="20000" latitude="90" longitude="59"/>
9
Simulating Device Location Loading the path XML file while MIDlet is running XML file
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.