Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 484
Registered: ‎07-17-2008
My Device: Not Specified

Test for Built In GPS

What is the best way to determine if a device has built in GPS capabilites?

 

System properties return a value for location API version even if no GPS is available.

 

Do I have to use the location API and wait for it to timeout before I will know?

 

Thanks,

 

Jon

Developer
Posts: 29
Registered: ‎09-12-2008
My Device: Curve 8330

Re: Test for Built In GPS

I've not played with this, but if you use the LocationProvider, and provide a Criterion that specifies Autonomous mode, and there is no GPS source, does it time out returning OUT_OF_SERVICE?  I would have thought that it would return OUT_OF_SERVICE quickly if you ask it for this kind of answer and it knows that it will never be able to provide it.  Now, if there IS a GPS device and it is not able to get a fix, then I would expect a timeout in that situation.  Have you tried it?
Developer
Posts: 39
Registered: ‎07-18-2008
My Device: Not Specified

Re: Test for Built In GPS

try { _locationProvider = LocationProvider.getInstance(null); if ( _locationProvider == null ) {//NO GPS, do something.} else {//You have GPS do something} } ....

 

Developer
Posts: 484
Registered: ‎07-17-2008
My Device: Not Specified

Re: Test for Built In GPS

So If I define a Criteria and it returns null, try getting the LocationProvider again with null Criteria and if that returns null then no GPS?

 

The Java docs mention that null will be returned if there are other location providers available.

 

Developer
Posts: 484
Registered: ‎07-17-2008
My Device: Not Specified

Re: Test for Built In GPS

[ Edited ]
I'm still having problems trying to detect if the device has GPS capability.

For example, on the 8100 which has no built in GPS if I call locaitionProvider.getInstance(cr)
it will return a LocationProvider instance of javax.microedition.location.BluetoothSerialPortGPSProvider
even though I don't have a bluetooth GPS puck hooked up to this device.

So then I have to wait for that provider to timeout before I know that the device doesn't have bluetooth GPS?

Isn't there any easier way to do this?
I just want to know if the device has gps capability and if it's enabled.

Jon
Message Edited by jonberry on 10-15-2008 06:16 PM