黑莓 - 更改设备上的纬度和经度以测试应用程序

发布于 2024-07-21 16:50:22 字数 106 浏览 4 评论 0原文

我想在设备上测试我的应用程序。 是否可以在设备设置中的某个位置对纬度和经度值进行硬编码,以便应用程序读取这些值而不是当前位置?

我想在当前位置以外的不同位置测试我的应用程序。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖阳 2024-07-28 16:50:25

GPS 模型内部

如果您有权访问应用程序代码,则始终可以为 LocationProvider 因此它将从文件或 RecordStore 读取位置和速度数据并将其作为 LocationProvider 返回。 cs.umn.edu/~czhou/docs/jsr179/lapi/javax/microedition/location/Location.html" rel="nofollow noreferrer">位置,类似于

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        
    }
}

您的位置的模型

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;
    }
}

然后在屏幕上的某个位置

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

外部 GPS 模型

另一种选择是总体模拟 GPS 信号。
步骤是:

  • 配置设备 GPS 接收器
    蓝牙(例如)
  • 设置一些
    桌面上的开源 GPS 服务器
    生成位置数据
    蓝牙
  • 更改配置/代码
    GPS 服务器模拟位置数据

其他选项

通过使用某些无线电材料(如铝箔等)屏蔽 GPS 接收器,可能会不受控制地更改位置 GPS 数据:)

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) :)

今天小雨转甜 2024-07-28 16:50:24

在 BB 模拟器中,您可以转到 Simulate > GPS 位置。 单击添加按钮并输入名称、纬度和经度。 单击“保存”,模拟器将开始将您的新位置提供给应用程序。 请注意,下拉列表中显示的任何位置都是模拟器将报告的位置。

In the BB simulator you can go to Simulate > GPS Location. Click the Add button and enter in a name, latitude and longitude. Click save and the simulator will start feeding your new location to the apps. Note that whatever location is displayed in the drop down is the one that will be reported by the simulator.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文