09-26-2012 09:30 AM
Hi All
I need to get the current location coordinates on the start of the app.Iam working out in 8520 simulator.
Iam trying out with a sample code here but getting the location=null in 8520 simulator and in 9800 simulator iam getting the coordinates as 43.6775,-80. 7339
Criteria criteria = new Criteria();
criteria.setVerticalAccuracy(50);
criteria.setHorizontalAccuracy(50);
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(
Criteria.POWER_USAGE_HIGH);
try {
screen.setMessage("Getting location...");
LocationProvider provider =
LocationProvider.getInstance(criteria);
Location location = provider.getLocation(-1);
QualifiedCoordinates qualifiedCoordinates =
location.getQualifiedCoordinates();
screen.setLocation(qualifiedCoordinates.getLongit
qualifiedCoordinates.getLatitude());
Plzzzz any help....
Thanks.
09-26-2012 10:49 AM
are you sure that BB 8520 have GPS?
sorry for my english.
09-26-2012 04:25 PM
Have a good look at this KB article and the code supplied is useful too:
http://supportforums.blackberry.com/t5/Java-Develo
09-27-2012 02:21 AM
Hi peter,
I tried with this kb article also but iam unable to get the correct coordinates it is always showing 43.6775,-80.7339 but i need to get 17.492273,78.356008
plzzz help me out
Thanks
09-27-2012 04:39 AM
If you look at the Simulator, in the 'Windows' menu you will see a Simulate menu option, click on that and you will see for most devices, a GPS option. This is the location that it will get when using GPS. I'm not sure how you can simulate any of the other location options, but if you change this I suspect it might change the others too.
09-27-2012 06:06 AM
You can use this code for getting current location ... Dont use this code directly. plz understand than use...
Class test
{
Criteria criteria;
LocationProvider locationProvider;
switch (MODE) {
case Constants.GPS_MODE_SATELLITE: //1
criteria.setCostAllowed(false);
break;
case Constants.GPS_MODE_CELLSITE: //2
criteria.setHorizontalAccuracy(Criteria.NO_REQUIRE
criteria.setVerticalAccuracy(Criteria.NO_REQUIREME
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(Criteria.POW
// Will wait for two minutes
criteria.setPreferredResponseTime(120000);
break;
}
private LocationProvider getLocationProvider() throws LocationException {
return LocationProvider.getInstance(criteria);
}
}