私はリアルタイムの位置情報リスニングアプリを作成しており、3 秒ごとに位置情報の更新を呼び出す必要があります。
融合した場所を使用します。
私の間隔は 3 秒に設定されていますが、この間隔の最小値は5 秒のようです。
コード:
public class GpsService extends Service implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener {
private static int UPDATE_INTERVAL = 1000 * 3; // /< location update interval
private static int FASTEST_INTERVAL = 1000 * 3; // /< fastest location update interval
private static int DISPLACE_METERS = 10; // displacement in meters, not used atm
private LocationRequest mLocationRequest;
private LocationWrapper mLastLocation;
...
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(UPDATE_INTERVAL);
mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
...
@Override
public void onLocationChanged(Location location) {
mLastLocation = new LocationWrapper(location);
log("onLocationChanged" + " " + mLastLocation.toString());
}
ログキャット:
03-11 14:35:41.559: I/Locationing_GpsService(7410): Lat: 47.513878
03-11 14:35:41.559: I/Locationing_GpsService(7410): Lng: 19.0362011
03-11 14:35:41.559: I/Locationing_GpsService(7410): Accuracy: 21.213 meters
03-11 14:35:41.559: I/Locationing_GpsService(7410): ===================
03-11 14:35:46.554: I/Locationing_GpsService(7410): Lat: 47.5138783
03-11 14:35:46.554: I/Locationing_GpsService(7410): Lng: 19.0362064
03-11 14:35:46.554: I/Locationing_GpsService(7410): Accuracy: 17.32 meters
03-11 14:35:46.554: I/Locationing_GpsService(7410): ===================
03-11 14:35:51.569: I/Locationing_GpsService(7410): Lat: 47.5138752
03-11 14:35:51.569: I/Locationing_GpsService(7410): Lng: 19.0362068
03-11 14:35:51.569: I/Locationing_GpsService(7410): Accuracy: 15.0 meters
logcat の日付を確認できます。遅延は 5 秒です: 41, 46, 51 Fused location に関する Google のドキュメントを読みましたが、間隔の最小値については何も見つかりませんでした。
助言がありますか?
編集:
ログに追加し、オブジェクトにgetTime()
解析すると、 5 秒の遅延がより明確にわかります。Date
03-11 15:16:01.851: I/Locationing_GpsService(16747): Lat: 47.5138798
03-11 15:16:01.851: I/Locationing_GpsService(16747): Lng: 19.0362125
03-11 15:16:01.851: I/Locationing_GpsService(16747): Accuracy: 28.713 meters
03-11 15:16:01.851: I/Locationing_GpsService(16747): Time: Wed Mar 11 15:16:01 CET 2015
03-11 15:16:01.851: I/Locationing_GpsService(16747): =========================================================
03-11 15:16:06.946: I/Locationing_GpsService(16747): Lat: 47.5138765
03-11 15:16:06.946: I/Locationing_GpsService(16747): Lng: 19.0361987
03-11 15:16:06.946: I/Locationing_GpsService(16747): Accuracy: 20.902 meters
03-11 15:16:06.946: I/Locationing_GpsService(16747): Time: Wed Mar 11 15:16:06 CET 2015
03-11 15:16:06.946: I/Locationing_GpsService(16747): =========================================================
03-11 15:16:11.971: I/Locationing_GpsService(16747): Lat: 47.5138767
03-11 15:16:11.971: I/Locationing_GpsService(16747): Lng: 19.0361916
03-11 15:16:11.971: I/Locationing_GpsService(16747): Accuracy: 17.326 meters
03-11 15:16:11.971: I/Locationing_GpsService(16747): Time: Wed Mar 11 15:16:11 CET 2015
03-11 15:16:11.971: I/Locationing_GpsService(16747): =========================================================
編集2:
権限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />