0
我無法使用此功能讀取位置。當我試圖讓位置信息,它總是返回0海拔,經度0在BlackBerry上獲取GPS位置
void getirGps(){
Criteria myCriteria = new Criteria();
myCriteria.setCostAllowed(false);
try
{
LocationProvider myLocationProvider =
LocationProvider.getInstance(myCriteria);
try
{
Location myLocation = myLocationProvider.getLocation(300);
seTLatitude(myLocation.getQualifiedCoordinates().getLatitude());// sunlarıda bir public statıc dene..
seTLongitude(myLocation.getQualifiedCoordinates().getLongitude());
Dialog.alert("latitude = "+GPSThread.latitude +" longi"+GPSThread.longitude);
velocity = myLocation.getSpeed();
heading = myLocation.getCourse();
timeStamp = myLocation.getTimestamp();
nmeaString = myLocation.getExtraInfo
("application/X-jsr179-location-nmea");
}
catch (InterruptedException iex)
{
Dialog.alert("InterruptedException");
return;
}
catch (LocationException lex)
{
Dialog.alert("LocationException lex");
return;
}
}
catch (LocationException lex)
{
Dialog.alert("LocationException lex2");
return;
}
}
public void doThis(){
MapView mapView = new MapView();
mapView.setLatitude((int) Threads.latitude);//39.9208, Longitude = 32.8541
mapView.setLongitude((int) Threads.longitude);
mapView.setZoom(10);
MapsArguments mapsArgs = new MapsArguments(mapView);
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, mapsArgs);
Dialog.alert("latitude = "+Threads.latitude +" longi"+Threads.longitude);
當我在模擬器中嘗試我的應用程序時,我更改菜單上的位置信息,gps locaiton標籤。 – 2010-11-10 13:52:44
我假設您擔心Dialog在doThis()中強行顯示零值。但是你沒有包含足夠的代碼來找出值從LocationProvider到doThis()方法的值。我建議你進一步分解你的問題 - 在LocationProvider附近添加一些打印輸出,看看它返回的值是什麼,以及返回時的值。 – 2010-11-11 14:29:15