O'Reilly logo

Location-Aware Applications by Murat Aktihanoglu, Richard Ferraro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix A. Java code examples referred to in chapter 2

The following listing is an example of the Java code required to fetch the handset location obtained via GPS for use within a Java application.

Listing A.1. Fetching a handset’s location from the inbuilt GPS receiver
Criteria cr = new Criteria();
cr.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW
cr.setAddressInfoRequired(false);
cr.setAltitudeRequired(false);
cr.setSpeedAndCourseRequired(false);
cr.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
cr.setVerticalAccuracy(Criteria.NO_REQUIREMENT);

//cr.setPreferredResponseTime(30);
locationProvider = LocationProvider.getInstance(cr);

The next listing is an example of the Java code required to fetch the handset location obtained via ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required