Free Trial

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


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Appendix A. Java code examples referred to in chapter 2

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


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial