我正在使用Gps獲取當前經緯度,在我的應用程序中,它與android 2.3.3很好地工作,甚至在我的一些更高版本的android設備上工作,但有時在一些設備中,它的行爲正好相反,儘管GPS顯示錯誤信息:GPS未連接,請打開GPS,這是我在gps未檢測到時使用的消息。任何人都可以請幫助我嗎? 下面是我的檢測並獲得GPSGps在某些應用程序中不工作有時用於android
private void bindgeocodelocation() {
latlong = new ArrayList<String>();
latlong = GeneralFunction.getcurrentlocation(Search.this);
if (latlong == null) {
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Location loc = lm
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 100, 1,
locationListener);
if (loc != null) {
latlong = new ArrayList<String>();
latlong.add("" + loc.getLatitude());
latlong.add("" + loc.getLongitude());
} else if (lm != null) {
lm.removeUpdates(locationListener);
}
}
}
private final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
try {
latlong = new ArrayList<String>();
latlong.add(location.getLatitude() + "");
latlong.add(location.getLongitude() + "");
// webviewdata();
} catch (Exception e) {
Log.e("Error", e.getMessage().toString());
}
}
@Override
public void onProviderDisabled(String provider) {
Log.i("Info", "Provider disable");
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
};
崗位培訓相關代碼 – 2014-09-25 06:38:10
發佈的代碼 – 2014-09-25 06:40:49
我認爲你必須使用最好的供應商insted的的LocationManager.NETWORK_PROVIDER – 2014-09-25 06:42:10