如何使地理围栏准确?

How to make geofences accurate?

我对地理围栏的准确性有疑问,因为用户的位置主要由完全糟糕的移动网络确定。

我的应用程序在选定地点周围使用地理围栏,当用户进入这些地点时会执行一些操作...我确认我的应用程序确实有效,因为当我打开 google 地图时,位置的准确性会增加,然后我的地理围栏被触发了。

我目前的解决方案是将位置管理器与 gps 提供商一起使用,它每分钟获取一次位置,但它似乎会影响电池寿命,并且会在一段时间后停止。

我的问题是:例如,有没有办法使地理围栏精确到 60 米半径?或者有什么方法可以获取用户的精确位置更新?

提前致谢

通过关注此主题,您将对准确性有更好的了解:

How to make Geo Fencing alert more accurate in Android

一旦你创建了你的地理围栏,你就可以开始 ping 你的 GPS 直到你得到 ENTER 转换。我试过这种方式,我得到了更好的准确性。

简单的 ping GPS 服务:

public class GPSService extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {

GoogleApiClient mGoogleApiClient;
LocationRequest locationRequest;

public GPSService() {
}

@Override
public IBinder onBind(Intent intent) {
    // TODO: Return the communication channel to the service.
    throw new UnsupportedOperationException("Not yet implemented");
}

@Override
public void onCreate() {
    super.onCreate();


    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    mGoogleApiClient.connect();


}

@Override
public void onLocationChanged(Location location) {


    Utility.ReadAndWriteData(this, Utility.readFileName(this), "Still Geofence is not triggered!!!");

}

@Override
public void onConnected(Bundle bundle) {

    locationRequest = LocationRequest.create();
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    locationRequest.setFastestInterval(1000);
    locationRequest.setInterval(2000);
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,locationRequest,this);

}

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {

}

@Override
public void onConnectionSuspended(int i) {

}

@Override
public void onDestroy() {
    super.onDestroy();

    if(mGoogleApiClient.isConnected()) {

        LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);

    }
}