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

BlackBerry® World™ Development

Reply
New Member
Posts: 1
Registered: ‎03-18-2010
My Device: 9000
My Carrier: Programmer

get location information

I use following code for get location pointers but these code return latitude and longitude 0.

 

Criteria criteria = new Criteria();

LocationProvider provider = LocationProvider.getInstance(criteria);

Location location = provider.getLocation(-1);

QualifiedCoordinates qc = location.getQualifiedCoordinates();

lat = qc.getLatitude();

lng = qc.getLongitude();

 

Can you help me to provide the correct way to get location information from devices.

 

 

Thank you

Developer
Posts: 109
Registered: ‎12-04-2008
My Device: Playbook, Torch 9800, Storm 9530, Tour 9630
My Carrier: Telus

Re: get location information

[ Edited ]

You should probably make sure your provider is initialising correctly with something like: if (provider != null) { ,then call location}.

You could also wrap the Location location = provider.getLocation(-1); call in a Try-Catch and catch InteruptedException and LocationException.

 

HTH

blueinc

 

[Edit:

You should also REALLY take a look at this thread:

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800703/What_Is...

The sample application code in the link at the bottom of the article was probably the single most valuable link I ever clicked on...well, from a GPS coding standpoint, that is Smiley Happy

PlayBook Apps: Sudoku Pro
Smartphone Apps: Compass | MultiClock