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 ...

Get Location-Aware Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.