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.
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 A-GPS for use within a Java application while limiting power consumption.
cr.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW cr.setCostAllowed(MIDlet.useAssistedGPS); 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);
This listing shows the format in which the cell/get API key returns information on the user’s exact position.
<rsp stat="ok"> <cell range="6000" lac="0" lat="53.4044704705058" nbSamples="47" lon="27.4110088888429" cellId="29513" mcc="250" mnc="99"/> </rsp>