Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
690 views
in Technique[技术] by (71.8m points)

android - Google+ signin - handleSignInResult returns false after customizing signin button

I'm following the sample code given by Google to integrate Google plus with android. https://github.com/googlesamples/google-services/blob/master/android/signin/app/src/main/java/com/google/samples/quickstart/signin/SignInActivity.java

That code sample worked perfectly fine until I added some changes as follows.

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
 .requestScopes(new Scope(Scopes.PLUS_LOGIN))
 .requestEmail()
 .build();

mGoogleApiClient = new GoogleApiClient.Builder(this)
 .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
 .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
 .build();

signinGoogleBtn = (SignInButton) findViewById(R.id.signingoogleBtn);
signinGoogleBtn.setSize(SignInButton.SIZE_STANDARD);
signinGoogleBtn.setScopes(gso.getScopeArray());

I added Google+ scopes to GoogleSignInOptions in order to customize the signin button. Then GoogleSignInResult and handleSignInResult always returns false.

if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        handleSignInResult(result);

Could anyone please help me to fix this issue?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Hey i was having same problem, i think in your case either you have not put your google-services.json file inside your app folder or you are not running your signed apk file if this the case first sign your apk and then paste this apk file in your mobile and from their open it, i mean don't run your app from android studio because what it does is it does not run signed apk file on mobile device. Hope this works :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...