2014-04-01 4 views
0

나는 PendingIntent와 함께 requestLocationUpdates를 호출합니다. 나중에이 요청이 여전히 활성 상태인지 여부를 알고 싶습니다. 어떻게해야합니까?Android 앱 LocationClient가 위치 업데이트를 요청하는지 확인

내가 removeLocationUpdates를 호출했는지는 알지만 위치 업데이트가 중지되고 잘못하고 싶지 않은 다른 방법이있을 수 있습니다.

이 질문은 지오 펜스에 관한 내용이 아닙니다. 에 따르면

답변

1

:

http://developer.android.com/reference/com/google/android/gms/location/LocationClient.html

당신은 지오 펜스를 찾는 경우 :

static List<Geofence> getTriggeringGeofences(Intent intent) 
Returns a list of geofences that triggers this geofence transition alert. 

그렇지 않으면 :

아니, 당신은 일반적인 방법으로 요청할 수 없습니다. 청취자가있는 경우 관심있는 방법이 몇 가지 있습니다.

boolean isConnectionCallbacksRegistered(GooglePlayServicesClient.ConnectionCallbacks listener) 
Returns true if the specified listener is currently registered to receive connection events. 


    boolean isConnectionFailedListenerRegistered(GooglePlayServicesClient.OnConnectionFailedListener listener) 
    Returns true if the specified listener is currently registered to receive connection failed events. 

    void  registerConnectionCallbacks(GooglePlayServicesClient.ConnectionCallbacks listener) 
    Registers a listener to receive connection events from this GooglePlayServicesClient. 

    void  registerConnectionFailedListener(GooglePlayServicesClient.OnConnectionFailedListener listener) 

    Registers a listener to receive connection failed events from this GooglePlayServicesClient. 

이 모두가 특정 수신기에 대해 알려줍니다. 나는 "당신에 대해 무엇이라도 듣는 사람이 있습니까?"라는 질문에 일반적으로 대답 할 코드를 보지 못합니다.

아마도 내부 검사를 사용하여 내부 구조를 표시하도록 강제 할 수는 있지만, 다른 방식으로는 덜 못생긴 방식으로 수행 할 수 있습니다.

달성하려는 작업은 무엇입니까?

편집 :뿐만 아니라 워드 프로세서

:

공공 무효 requestLocationUpdates (LocationRequest 요청, PendingIntent callbackIntent) 지정된 PendingIntent에 콜백

요청 위치 업데이트됩니다.

이 방법은 배경 사용 사례에 적합합니다. 시스템에서 시스템을 종료 한 경우에도이 방법은 위치 업데이트를 수신하는 데 특히 위치 업데이트에 적합합니다. 이렇게하려면 시작된 서비스에 대해 PendingIntent를 사용하십시오. 전경 사용 사례의 경우 메서드의 LocationListener 버전을 사용하는 것이 좋습니다 (requestLocationUpdates (LocationRequest, LocationListener) 참조).

이 PendingIntent에 등록 된 이전 LocationRequest는 모두 으로 바뀝니다.

이것은 무엇을 의미합니까? 당신이 명시 적으로

public void removeLocationUpdates (PendingIntent callbackIntent) 

2를 호출 할 때까지

1) 귀하의 요청이 앱이 시스템에 의해 살해 된 경우에도 마찬가지입니다) 개최되며, unstaged되지 않습니다. (배경 사용 사례로 가정합니다. 전경 유스 케이스에 대해 잘 모르겠습니다).

3) LocationClient가 업데이트 수신을 중단 한 경우 귀하의 의도에 통지되지 않습니다. 다음과 같이 호출해야합니다.

isConnected() 클라이언트가 현재 서비스에 연결되어 있는지 확인하여 다른 방법에 대한 요청이 성공하는지 확인합니다. boolean
isConnecting() 클라이언트가 서비스에 연결하려고 시도하는지 확인합니다.

위치 업데이트는 KEY_LOCATION_CHANGED 키와 위치 값의 인 텐트로 전송됩니다.

매개 변수 요청 업데이트 위치 요청입니다. callbackIntent 각 위치 업데이트에 대해 보류중인 의도입니다.

나중에 포인트 클라 이언트는 LocationClient가 연결되어 있는지 확인합니다. 그렇지 않은 경우에도 Intent가 해고되지 않는다고 가정하는 것이 안전합니다. 다시 연결되면 의도가 등록되어야합니다.

+0

명확한 질문을 참조하십시오 – cja

+0

제 편집을 참조하십시오. –

+0

+1을 많이 쓰면 – cja