java - 使用 GPS(位置 API)时出现位置异常

标签 java java-me geolocation

我已经在 sonyerricsom T700 移动设备上下载了谷歌地图应用程序,它工作正常,它的 java 应用程序。所以根据我的理解,它也使用位置 API。 这个link显示它没有GPS。 但它显示 map ,甚至在谷歌地图上定位设备上点击的照片。

所以我使用Location API(JSR-179)在j2me中尝试了下面的代码。它在模拟器上工作正常。 但是当我在索尼 erisccon T700 移动设备上尝试相同的操作时,出现以下异常:

异常(exception):

javax.microedition.location.LocationException:All service providers are out of service.

代码:

try {

// Create a Criteria object for defining desired selection criteria
Criteria cr = new Criteria();
LocationProvider lp = LocationProvider.getInstance(cr);    
l = lp.getLocation(60);    
c = l.getQualifiedCoordinates();    
//cityMap.setCategories(selectedCategories);
if (c != null) {
// use coordinate information
double lat = c.getLatitude();    
//latitude="";
latitude = ""+lat;
Latitude.setString(latitude);
double lon = c.getLongitude();
longitude =""+lon;
Longitude.setString(longitude);
}
}
catch (LocationException e) {
alert = new Alert("LocationException");
alert.setString("Unable to retrive location information:" + e);
alert.setTimeout(2000);
display.setCurrent(alert);
// not able to retrive location information
//e.printStackTrace();
} catch (InterruptedException ie) {
alert = new Alert("InterruptedException");
alert.setString("Operation Interrupted:" + ie);
alert.setTimeout(2000);
display.setCurrent(alert);    
}    
}

请给我建议任何解决方案......

感谢和问候。

最佳答案

是的,我敢打赌这不是您从 GPS 获得的准确位置。

Google 还有其他方式来查找您的位置...可能是使用 Cell ID。幸运的是,索尼爱立信手机很容易找到 Cell ID,请参阅 here 。获得后,您可以在 cell ID database 中查找它。找到位置。

关于java - 使用 GPS(位置 API)时出现位置异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5387413/

相关文章:

java - 使用 zxing lib 从 QR 码获取原始字节(或从 BitMatrix 转换)

java - java中出现hibernate session 错误

java - 如何通过J2ME连接sqlserver2000创建数据库?

android - Phonegap 地理定位不适用于 Android(Nexus 设备)

java - Java 编译器与 Linux/Windows 上的编译器相同吗?

java - 如何使用数组对象?

java-me - J2ME有舍入功能吗?

java - 如何用 Java 创建面向移动设备的多平台共享库?

手机重启后Android获取位置为空

javascript - 函数声明不应放在 block 中