구글을 하루종일 검색 해봐서 이제 내용 정리도 다됐는데...
매니페스트에 GET_ACCOUNTS, USE_CREDENTIALS, INTERNET 선언 하였구
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_PROFILE)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.build();
한 뒤에
@Override
public void onConnected(Bundle arg0) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
String accountName = Plus.AccountApi.getAccountName(mGoogleApiClient);
Account account = new Account(accountName, GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
SeeOnLog.log("GOOGLE JOIN"+"accountName: "+(accountName));
SeeOnLog.log("GOOGLE JOIN"+"person null? "+(currentPerson==null));
if(currentPerson != null){
String personName = currentPerson.getDisplayName();
String psersonId = currentPerson.getId();
String personPhotoUrl = currentPerson.getImage().getUrl();
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
SeeOnLog.log("personName: "+personName);
SeeOnLog.log("psersonId: "+psersonId);
SeeOnLog.log("email: "+email);
SeeOnLog.log("personPhotoUrl: "+personPhotoUrl);
}
}
이렇게 하였는데요... accountName은 제 구글 계정이 잘 나옵니다.
근데 getCurrentPerson에서 계속 null이 나와서 필요한 Id 값을 추출할 수가 없네요..
그리고 추가로 현재 안드로이드 스튜디오로 하지 않고 이클립스로 하고 있는데
https://developers.google.com/identity/sign-in/android/start 여기 링크에 보면 하단에 예제 소스들이 있는데
GoogleSignInOptions 같은경우 제 구글플레이서비스라이브러리에 존재하지 않는 클래스 입니다.
그래서 SDK Manager에 가서 업데이트를 해보고 난리를 쳐도 저 클래스는 생기지 않는데...
최신 구글플레이서비스라이브러리는 이클립스에 어떻게 import 할 수 있나요?
아... 이거 미치겠네요... 안드 스튜로 옮겨야하나... ㅠ