2013-12-13 8 views
2

official announcement에 따르면 Google+ 로그인 없이는 Google+ 프로필이없는 사용자를 지원합니다.Google+ 프로필이없는 사용자를위한 Google+ 로그인

그러나 Google+ 프로필이없는 계정에서 official examples을 방문하면 Google+에 가입 할 수있는 옵션 만 제공됩니다.

이 기능을 구현하는 방법은 무엇입니까? 공식 문서도 확인했지만이 주제에 대한 참조를 찾을 수 없습니다.

+0

아직 답변을 찾을 수 없습니까? 나는 똑같은 어려움에 직면 해있다. – Nebula

+0

예. 새로운 [이전 문서] (https://developers.google.com/+/api/auth-migration#sign-in)를 사용해보세요. 프로필 범위를 사용하는 것입니다. "프로필 범위와 함께 Google+ 로그인 버튼을 추가하면 사용자의 기본 정보에만 액세스 할 수있는 간단하고 안전한 방법으로 사용자를 인증 할 수 있습니다. 사용자는 Google+를 만들지 않습니다. 윤곽." – zugaldia

+0

그래, 나는 이것을 시도했다. 그러나 나는 여전히 "create a profile"프롬프트를 얻는다. 'GoogleApiClient'를 사용합니까? 어떻게 수정했는지에 대한 스 니펫을 게시 할 수 있습니까? – Nebula

답변

0

우리는이 작업을해야합니까?

package com.example.googleplusauth; 

import com.google.android.gms.common.ConnectionResult; 
import com.google.android.gms.common.api.GoogleApiClient; 
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks; 
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener; 
import com.google.android.gms.plus.Plus; 

import android.app.Activity; 
import android.content.Intent; 
import android.content.IntentSender.SendIntentException; 
import android.os.Bundle; 

public class MainActivity extends Activity implements ConnectionCallbacks, 
     OnConnectionFailedListener { 

    /* Request code used to invoke sign in user interactions. */ 
    private static final int RC_SIGN_IN = 0; 

    /* Client used to interact with Google APIs. */ 
    private GoogleApiClient mGoogleApiClient; 

    /* 
    * A flag indicating that a PendingIntent is in progress and prevents us 
    * from starting further intents. 
    */ 
    private boolean mIntentInProgress; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     mGoogleApiClient = new GoogleApiClient.Builder(this) 
       .addConnectionCallbacks(this) 
       .addOnConnectionFailedListener(this) 
       .addApi(Plus.API, null) 
       .addScope(Plus.SCOPE_PLUS_PROFILE) 
       .build(); 
    } 

    @Override 
    protected void onActivityResult(int requestCode, int responseCode, Intent intent) { 
     if (requestCode == RC_SIGN_IN) { 
      mIntentInProgress = false; 

      if (!mGoogleApiClient.isConnecting()) { 
       mGoogleApiClient.connect(); 
      } 
     } 
    } 

    @Override 
    protected void onStart() { 
     super.onStart(); 
     mGoogleApiClient.connect(); 
    } 

    @Override 
    protected void onStop() { 
     super.onStop(); 

     if (mGoogleApiClient.isConnected()) { 
      mGoogleApiClient.disconnect(); 
     } 
    } 

    @Override 
    public void onConnectionFailed(ConnectionResult result) { 
     if (!mIntentInProgress && result.hasResolution()) { 
      try { 
       mIntentInProgress = true; 
       startIntentSenderForResult(
         //result.getIntentSender(), 
         result.getResolution().getIntentSender(), 
         RC_SIGN_IN, null, 0, 0, 0); 

      } catch (SendIntentException e) { 
       // The intent was canceled before it was sent. Return to the 
       // default 
       // state and attempt to connect to get an updated 
       // ConnectionResult. 
       mIntentInProgress = false; 
       mGoogleApiClient.connect(); 
      } 
     } 
    } 

    @Override 
    public void onConnected(Bundle connectionHint) { 
     // We've resolved any connection errors. mGoogleApiClient can be used to 
     // access Google APIs on behalf of the user. 
    } 

    @Override 
    public void onConnectionSuspended(int cause) { 
     mGoogleApiClient.connect(); 
    } 

} 
관련 문제