在我的应用程序中,需要取当前的位置信息,我使用下面的代码;并称之为buttonclick,但它不能在设备和模拟器中工作,如果任何人有任何想法请帮助。GPS位置信息问题
private void getLocationServices(){
Thread geoThread=new Thread(){
public void run(){
try{
Criteria myCriteria = new Criteria();
myCriteria.setCostAllowed(false);
try{
LocationProvider myLocationProvider = LocationProvider.getInstance(myCriteria);
try{
locationaddress=new AddressInfo();
Location myLocation = myLocationProvider.getLocation(300);
_lattitude = myLocation.getQualifiedCoordinates().getLatitude();
_longitude = myLocation.getQualifiedCoordinates().getLongitude();
int intLatitude = (int) _lattitude * 100000;
int intLongitude = (int) _longitude * 100000;
try{
Landmark[] results= Locator.reverseGeocode(intLatitude, intLongitude, Locator.ADDRESS);
if (results != null && results.length > 0) {
locationaddress=results[0].getAddressInfo();
lblLoc.setText(locationaddress.getField(AddressInfo.CITY));
}
}catch (Exception e) {
// TODO: handle exception
}
}catch (Exception e) {
// TODO: handle exception
}
}catch (Exception e) {
// TODO: handle exception
}
}catch (Exception e) {
// TODO: handle exception
}
}
};
geoThread.start();
}
你有它不工作更多的细节?例如,你是否遇到异常?如果是这样,在哪一行?或者你的结果与预期不同?需要一些关于什么不工作的更多细节。 – 2011-02-08 16:59:04