0

I have used the GoogleApiClient to get the location information. My requirement is to find the accurate location information.

In the location request I have set the priority as PRIORITY_HIGH_ACCURACY, then when I was in in door am not getting any location update when I was indoor. I need the location object needs to be returned it may be last known location.

And also I have tried PRIORITY_LOW_POWER. But it never uses the GPS to get the location information.I think using this may be bit of inaccurate.

I need the better location information when outside by using GPS and also the last known location information to be returned when I was indoor. So which priority is suitable for me?

And also always am getting the Altitude and Bearing as 0. Always am getting the fused provider. I think GoogleApiClient does not provide the provider detail which gives the location information.

Added Clarification:

I have the below implementation:

//Request for location update
LocationServices.FusedLocationApi.requestLocationUpdates(
                            mGoogleApiClient, mLocationrequest,
                            mLocationUpdatePendingIntent);


//Intent service where i receive the location information 
public LocationIntentService() {        
     super("LocationService");  
}
protected void onHandleIntent(Intent locationIntentObj) {
}


//Stop Location Update
LocationServices.FusedLocationApi.removeLocationUpdates(
                    mGoogleApiClient, mLocationUpdatePendingIntent);

In my case how can I get the last known location information from the API.

Please help me on this.

4

2 に答える 2

3

[...] その後、私がドアの中にいたとき、私が屋内にいたときに位置情報が更新されません。[...] また、常に高度と方位を 0 として取得しています。

屋内では GPS 衛星にアクセスできません。これらの値は GPS によって提供されます。

setInterval(...)メソッドとを使用することをお勧めしますsetFastestInterval(...)。これにより、あなたは次のように言っています:

少なくともintervalミリ秒ごとに任意の場所が必要ですが、それよりも早く適切な場所あれば、fastestIntervalミリ秒ごとに処理できます。

ヒューズがミリ秒単位でGPS に接続しない場合、intervalバックグラウンドでネットワーク プロバイダーにフォールバックする必要があります (その間、Wi-Fi から正確な位置情報を取得する必要があります)。

FusedLocationProviderApi.getLastLocation(GoogleApiClient)定期的なリスニングを設定する前に、 メソッドを使用してください。これはすぐに戻りますが、精度は異なる場合があります。

編集:上記が機能しない場合...私のプロジェクトでは、バランスの取れた電力優先度で常にバックグラウンドで融合プロバイダーを使用しています。次に、標準の GPS プロバイダーに追加の質問をします。

于 2014-12-08T14:32:57.190 に答える
0

はい、次のコード スニペットを使用して、最後に確認された場所を取得できます。

/**
 * Remove the user location update
 */
public void removeLocationUpdate() {
    if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
        //Remove the location update
        LocationServices.FusedLocationApi.removeLocationUpdates(
                mGoogleApiClient, mLocationUpdatePendingIntent);
        //A status message updated to the UI
        mAppUtilInstance.broadcastStatusMessage(mContext,
                Constants.STATUS_MSG_116, Constants.STATUS_CODE_116);
    }
    if (Constants.locationInformationEntity == null) {
        //Getting the last known location
        Location mLocationIntentObject = LocationServices.FusedLocationApi
                .getLastLocation(mGoogleApiClient);
        if (mLocationIntentObject != null) {
            //Storing as entity 
            mAppUtilInstance.setLocationInformationEntity(mContext,
                    mLocationIntentObject);
        }
    }
}

位置情報の更新を削除すると、屋内にいるときに API が位置情報を提供するかどうかを確認しています。API が提供に失敗した場合、ロケーション リクエストが削除されたときに、既知の最新のロケーション情報を取得しています。

これが、融合されたロケーションAPIで作業している他の人に役立つことを願っています.

于 2014-12-09T07:52:08.633 に答える