Java – Blackberry – change latitude and longitude on the device to test app


I want to test my app on the device. Is it possible to hard code the latitude and longitude values somewhere in the device settings so the app reads those instead of the current location?

I want to test my app for different locations other than my current location.

Best Solution

Inside GPS mockup

If you have access to your application code, you can always create a mockup implementation for LocationProvider so it will read location and speed data from file or RecordStore and return it as a Location, something like

public class MockupLocationProvider extends LocationProvider {

    public MockupLocationProvider() {
        //prepare a file or RecordStore with locations here

    public Location getLocation(int arg0) throws LocationException,
            InterruptedException {      
        //read data from file or RecordStore
        double latitude = 321;
        double longitude = 34;
        float altitude = 21;
        //create and return location
        Location result = new GPSLocation(latitude, 
            longitude, altitude);       
        return result;

    public int getState() {
        // mockup location provider always available 
        return LocationProvider.AVAILABLE;

    public void reset() {
        // your code        

    public void setLocationListener(LocationListener listener, 
            int interval, int timeout, int maxAge) {
        // your code        

and mockup for your Location

public class GPSLocation extends Location {    
    double _latitude, _longitude;
    float _altitude, _horAcc = 0, _verAcc = 0, _speed;
    public GPSLocation(double lat, double lon, float alt) {
        init(lat, lon, alt);
    public GPSLocation(double lat, double lon, float alt, float spd) {
        init(lat, lon, alt);
        _speed = spd;
    private void init(double lat, double lon, float alt) {
        _latitude = lat;
        _longitude = lon;
        _altitude = alt;
    public QualifiedCoordinates getQualifiedCoordinates() {
        QualifiedCoordinates c = new QualifiedCoordinates(_latitude,
                _longitude, _altitude, _horAcc, _verAcc);
        return c;
    public float getSpeed() {
        return _speed;
    public String toString() {
        String result = "Lat:" + String.valueOf(_latitude) + "|Lon:"
                + String.valueOf(_longitude) + "|Alt:"
                + String.valueOf(_altitude);
        return result;

Then somewhere on the screen

    MockupLocationProvider gpsProvider = new MockupLocationProvider();
    GPSLocation loc = (GPSLocation)gpsProvider.getLocation(0);
    add(new RichTextField(loc.toString())); 

Outside GPS mockup

Another option is to generally mockup GPS signals.
Steps are:

  • configure device gps receiver for bluetooth (for ex.)
  • setup some opensource gps server on your desktop to produce location data over bluetooth
  • change configuration/code of gps server to mockup location data

Other options

There is a possibility to uncontrolled change of location gps data by shielding gps receiver with some radio-material (like alluminium foil or so) :)

Related Question