2014-06-13 4 views
0

을 통합하는 동안 이상한 오류가 발생했습니다. 응용 프로그램에이 URL https://developers.google.com/+/mobile/android/sign-in의 응용 프로그램에 Google 플러스를 통합하고 있지만 로그인 할 수있는 Google+ 플러스 계정을 선택할 수없고 ConnectionResult에서 항상 ConnectionResult {statusCode = SIGN_IN_REQUIRED, resolution = PendingIntent {4223c668 : [email protected]}} ... 내가 링크를 많이 시도하고 생성 및 클라이언트 ID를 삭제 그 날 여기 작동하지 않는 것은 내 코드 당신은 아무것도하지Google 플러스

@Override 
protected void onCreate(Bundle savedInstanceState) { 
mGoogleApiClient = new GoogleApiClient.Builder(this) 
     .addConnectionCallbacks(this) 
     .addOnConnectionFailedListener(this) 
        .addApi(Plus.API) 
     .addScope(Plus.SCOPE_PLUS_LOGIN).build(); 

    btnGooglePlus = (SignInButton) findViewById(R.id.sign_in_button); 
    btnGooglePlus.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      if (v.getId() == R.id.sign_in_button 
        && !mGoogleApiClient.isConnecting()) { 
       mSignInClicked = true; 
      } 
     } 
    }); 


} 

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

@Override 
protected void onStop() { 
    super.onStop(); 
    if (mGoogleApiClient.isConnected()) { 
     mGoogleApiClient.disconnect(); 
    } 
} 

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 
    if (requestCode == RC_SIGN_IN) { 
     if (resultCode != RESULT_OK) { 
      mSignInClicked = false; 
     } 

     mIntentInProgress = false; 

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

@Override 
public void onConnectionFailed(ConnectionResult result) { 

    if (!mIntentInProgress) { 
     // Store the ConnectionResult so that we can use it later when the 
     // user clicks 
     // 'sign-in'. 
     mConnectionResult = result; 

     if (mSignInClicked) { 
      // The user has already clicked 'sign-in' so we attempt to 
      // resolve all 
      // errors until the user is signed in, or they cancel. 
      resolveSignInError(); 
     } 
    } 
} 

@Override 
public void onConnected(Bundle arg0) { 
    Toast.makeText(this, "User is connected!", Toast.LENGTH_LONG).show(); 
} 

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

/* A helper method to resolve the current ConnectionResult error. */ 
private void resolveSignInError() { 
    if (mConnectionResult.hasResolution()) { 
     try { 


    mIntentInProgress = true; 
      mConnectionResult.startResolutionForResult(this,  RC_SIGN_IN); 

     } 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(); 
     } 
    } 
} 

답변

1

입니다 귀하의 OnClickListener에 있습니다.

에서 onClick으로 전화하여 SIGN_IN_REQUIRED을 인식하고 이에 따라 로그인 절차를 시작해야합니다.

+0

작동하지 않습니다. 같은 결과가 나타납니다. ConnectionResult {statusCode = SIGN_IN_REQUIRED, resolution = PendingIntent {4223c668 : [email protected]}} – nileshbirhade

관련 문제