Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Appendix A. Java code examples referred to in chapter 2 - Pg. 280

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);