黑莓 - 变化的经度和纬度要测试的设备上的应用 [英] Blackberry - change latitude and longitude on the device to test app
问题描述
我要在设备上测试我的应用程序。是否有可能很难code在设备设置的纬度和经度值的地方,以便应用程序的读取,而不是当前位置?
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.
推荐答案
如果您可以访问你的应用程序code,你总是可以创建<一个一个样机实现href=\"http://www-users.cs.umn.edu/~czhou/docs/jsr179/lapi/javax/microedition/location/LocationProvider.html\"相对=nofollow> LocationProvider 所以它会读取文件或RecordStore中的位置和速度数据并返回它作为一个的地点,像
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
}
}
和样机为您的位置
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()));
以外的GPS样机
另一种选择是通常样机GPS信号。
步骤是:
Outside GPS mockup
Another option is to generally mockup GPS signals.
Steps are:
- 用于配置设备的GPS接收器
蓝牙(为前。) - 设置一些
在桌面上的开源GPS服务器
产生位置数据在
蓝牙 - 修改配置/ code
GPS服务器来样机位置数据
有是通过屏蔽GPS接收机与一些无线电材料(如铝箔铝制的左右)一种可能性,GPS定位数据的变化不会出现失控:)
There is a possibility to uncontrolled change of location gps data by shielding gps receiver with some radio-material (like alluminium foil or so) :)
这篇关于黑莓 - 变化的经度和纬度要测试的设备上的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!