BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 01-06-2010, 08:05 AM   #1 (permalink)
New Member
 
Join Date: Dec 2009
Model: 8300
PIN: N/A
Carrier: email
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting the current location using GPS in BlackBerry

Please Login to Remove!

Hi ,

I want to create a black berry application which will display the current location latitude and longitude when the location changes. So how can I test it inside black berry simulator 9530.

The code is mentioned below , Can any one help me ? Does the code is correct ?

package blackberry;

import javax.microedition.location.Location;
import javax.microedition.location.LocationListener;
import javax.microedition.location.LocationProvider;

import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;

public class GPSInformation extends MainScreen{

private LocationProvider locationProvider = null ;

private int _interval = -1 ;
private int _timeout = 1 ;
private int _maxAge = 1 ;

private double _longitude = 1 ;
private double _latitude = 2 ;

public GPSInformation() {

try {
locationProvider = LocationProvider.getInstance(null);

if(locationProvider != null) {
locationProvider.setLocationListener(new LocationListenerImp(), _interval, _timeout, _maxAge);
}
}
catch (Exception e) {

}
}

private class LocationListenerImp implements LocationListener {

public void locationUpdated(LocationProvider provider, Location location) {

if(location.isValid()) {
_longitude = location.getQualifiedCoordinates().getLongitude();
_latitude = location.getQualifiedCoordinates().getLatitude();
}

add(new LabelField("Longitude : " +_longitude));
add(new LabelField("Latitude : " +_latitude));
}

public void providerStateChanged(LocationProvider provider, int newState) {
// TODO Auto-generated method stub
}
}
}

Thanks
Offline  
Old 01-06-2010, 09:15 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Simulators for Blackberries equipped with GPSs are able to simulate GPS data.

You may want to move this topic to the developers' forum, and check out the thread there on how to post source code.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 01-06-2010, 10:39 AM   #3 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

When you start the simulator, select "Simulate / GPS Location" from the simulator menu.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Fulham WorkHorse Adaptable Ballast WH2-120-L 1 Pack
$20.36
Fulham WorkHorse Adaptable Ballast WH2-120-L 1 Pack picturePhilips Advance 10637 - ICN-3P32-SC T8 IntelliVolt Fluorescent Ballast 1 Pack
$32.43
Philips Advance 10637 - ICN-3P32-SC T8 IntelliVolt Fluorescent Ballast 1 Pack pictureBallast Quicktronic QTP 3X32T8/UNV ISH-SC HIGH BALLAST FACTOR
$10.0
Ballast Quicktronic QTP 3X32T8/UNV ISH-SC  HIGH BALLAST FACTOR pictureFulham 10091 - WHAM-120-213-L Fulham WorkHorse 1 Ballast
$26.06
Fulham 10091 - WHAM-120-213-L Fulham WorkHorse 1 Ballast pictureSylvania 150w HPS light bulb med ballast S55 Lot of 6
$55.0
Sylvania 150w HPS light bulb med ballast S55 Lot of 6 picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.