定位处理的优化

serial
Matthew 1 year ago
parent 95c0a9e814
commit 5dff91cfc9

@ -678,6 +678,12 @@ public class MicroPhotoService extends Service {
long startTime = (date.getTime() + 999) / 1000;
service.updateCaptureSchedule(startTime);
if (mPreviousLocation != null) {
service.updatePosition(mNativeHandle, mPreviousLocation.getLongitude(), mPreviousLocation.getLatitude(),
mPreviousLocation.getAccuracy(), mPreviousLocation.getTime() / 1000);
}
/*
try {
Location location = mLocationManager.getLastKnownLocation(mLocateType);
if (location != null) {
@ -686,6 +692,8 @@ public class MicroPhotoService extends Service {
} catch (Exception ex) {
ex.printStackTrace();
}
*/
}
}
};
@ -1104,6 +1112,7 @@ cellSignalStrengthGsm.getDbm();
////////////////////////GPS////////////////////
// private static final String GPS_LOCATION_NAME = android.location.LocationManager.GPS_PROVIDER;
private LocationManager mLocationManager;
private Location mPreviousLocation = null;
private String mLocateType;
private LocationListener mLocationListener = new LocationListener() {
@ -1113,11 +1122,12 @@ cellSignalStrengthGsm.getDbm();
if (mNativeHandle != 0) {
updatePosition(mNativeHandle, location.getLongitude(), location.getLatitude(), location.getAccuracy(), location.getTime() / 1000);
mLocationManager.removeUpdates(this);
// Close GPS
enableGps(false);
} else {
mPreviousLocation = location;
}
mLocationManager.removeUpdates(this);
// Close GPS
enableGps(false);
Log.i(TAG, "Time:" + location.getTime() + " Lon=" + location.getLongitude() + "Lat=" + location.getLatitude() + "Alt=" + location.getAltitude());
}

Loading…
Cancel
Save