views:

106

answers:

1

In this thread MSohm says "The GPS Services option does not toggle GPS on or off". This means that if a device has a built-in GPS receiver, then the code like this

LocationProvider provider = LocationProvider.getInstance(null);

should never return null regardless of GPS Services option.

But if I try the above code on both Curve 8310 (4.5.0) and Storm 9530 (4.7.0) simulators (both have a built-in GPS receiver), then i get null if GPS Services option is set to Location OFF. If I change GPS Services option to Location ON, then I get a non-null LocationProvider and I am able then to get locatoin, etc.

Is this a bug of simulators? Can anyone say how this would work on real device?

Thanks!

+1  A: 

My experience tells me that this is no bug

You can actually toggle the location on and off at the Blackberry options, under the GPS options.

What I would recommend is, after declaring the LocationProvider checking if it's null. If it's null, send a message to the user telling him that the GPS location is turned off and that he has to turn it on first in order to use the GPS.

You could also tell him where to change this settings.

You get the same behaviour on real devices so I think this is the best approach.

I tested this on a Curve 8530.

Keep in mind that, when running a simulator, you have to enable GPS in the simulator's window menu, that could be the reason on why you're getting a null LocationProvier at the simulator

Curro
Thanks, Curro, for your answer. I do check the LocationProvider for null and alert users to go to device GPS options to set the Location to ON. The point is this contradicted to what BB forum admin MSohm said, so I was not sure in my results. Now, looks like I can trust the got.
Arhimed