2016-07-16 1 views
0

현재 GooglePlayServices에 액세스하는 중입니다.HaveGooglePlayServices 및 OnConnected

나는 최근에 OAuth 2.0을 통해 GooglePlay Services에 액세스하는 다른 방법을 발견했습니다. 또한 gitHub에서 예제를 사용하여 예제를 사용하는 방법을 발견했습니다.

https://github.com/google/google-api-java-client-samples/blob/master/tasks-android-sample/src/main/java/com/google/api/services/samples/tasks/android/TasksSample.java

그러나, 나는 요청을 보내는 시작하기 위해 특별히 경우, 새로운 방법으로 약간의 혼란이었다.

Google Play 클라이언트를 사용하여 사용자의 위치에 액세스하려고 시도하고 있으며 locationRequest의 시작 위치를 알 수 없습니다. GoogleAPIClient를 사용할 때 onConnected가 시작되었습니다.

그러나이 구체적인 예에서 발견 한 바는 이것에 가깝습니다. 가장 가까운이었다

private void haveGooglePlayServices() { 
    if (credential.getSelectedAccountName() == null) { 
     chooseAccount(); 
    } else { 
     // This is where I think I need to start sending requests. 
     AsyncLoadTasks.run(this); 
    } 
    } 

이 가정의 권리인가, 아니면 위치 요청을 전송하기 시작하는 데 필요하고 다른 장소가 (코드 조각은 줄 206-197입니다)?

답변

0

@Override 
public void onConnected(Bundle connectionHint) { 
    mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
      mGoogleApiClient); 
    if (mLastLocation != null) { 
     mLatitudeText.setText(String.valueOf(mLastLocation.getLatitude())); 
     mLongitudeText.setText(String.valueOf(mLastLocation.getLongitude())); 
    } 
} 

같은

onConnected(Bundle connectionhint) 

에 코드를 작성하거나 link

을 확인
관련 문제