0
Google의 로그인 방식을 변경하면 로그인이 오래 걸릴 수 있습니다. 로그인을 구현하면 GoogleApiClient
이 던져졌지만 이제는 달라집니다 GoogleSignInClient
사용자가 로그인하거나 업적을 달성 할 때 팝업 뷰를 설정하는 방법에 대한 단서가 없습니다. 심지어 구글 문서 도구에서이에 대한 좋은 설명이 없기 때문에 어느 하나가setViewForPopUp (보기) google api (11.6.0) Google Play 로그인
//google variable
private static int RC_SIGN_IN = 9001;
private static final int RC_ACHIEVEMENT_UI = 9003;
GoogleApiClient googleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void SignIn(View view) {
GoogleSignInClient signInClient = GoogleSignIn.getClient(this,
GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
Intent intent = signInClient.getSignInIntent();
startActivityForResult(intent, RC_SIGN_IN);
}
private void signInSilently() {
GoogleSignInClient signInClient = GoogleSignIn.getClient(this,
GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
signInClient.silentSignIn().addOnCompleteListener(this,
new OnCompleteListener<GoogleSignInAccount>() {
@Override
public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
if (task.isSuccessful()) {
// The signed in account is stored in the task's result.
GoogleSignInAccount signedInAccount = task.getResult();
} else {
// Player will need to sign-in explicitly using via UI
}
}
});
}
@Override
protected void onResume() {
super.onResume();
signInSilently();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Toast.makeText(MainActivity.this, String.valueOf(requestCode), Toast.LENGTH_SHORT).show();
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
Log.d("fuck", String.valueOf(result));
// Toast.makeText(MainActivity.this,String.valueOf(result),Toast.LENGTH_SHORT).show();
if (result.isSuccess()) {
// The signed in account is stored in the result.
Toast.makeText(MainActivity.this, "Succesfull", Toast.LENGTH_SHORT).show();
GoogleSignInAccount signedInAccount = result.getSignInAccount();
} else {
String message = result.getStatus().getStatusMessage();
if (message == null || message.isEmpty()) {
message = getString(R.string.signin_other_error);
}
new AlertDialog.Builder(this).setMessage(message)
.setNeutralButton(android.R.string.ok, null).show();
}
}
}
public void achievement(View view) {
Games.getAchievementsClient(this, GoogleSignIn.getLastSignedInAccount(this))
.getAchievementsIntent()
.addOnSuccessListener(new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
startActivityForResult(intent, RC_ACHIEVEMENT_UI);
}
});
}
public void unlock(View view) {
Games.getAchievementsClient(this, GoogleSignIn.getLastSignedInAccount(this))
.unlock(getString(R.string.achievement_newbie));
}