Skip to content

Commit 625cc85

Browse files
committed
Re-connect to GoogleApiClient is we're not connected
Also listen for connection callbacks. Fixes #34
1 parent c5c5ed6 commit 625cc85

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

library/src/main/java/com/firebase/ui/auth/google/GoogleAuthProvider.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class GoogleAuthProvider extends FirebaseAuthProvider implements
3535
private TokenAuthHandler mHandler;
3636
private Activity mActivity;
3737
private Firebase mRef;
38-
private Integer onConnectedAction;
38+
private Integer onConnectedAction = 0;
3939

4040
public GoogleAuthProvider(Context context, Firebase ref, TokenAuthHandler handler) {
4141
mActivity = (Activity) context;
@@ -48,6 +48,7 @@ public GoogleAuthProvider(Context context, Firebase ref, TokenAuthHandler handle
4848

4949
mGoogleApiClient = new GoogleApiClient.Builder(mActivity)
5050
.enableAutoManage((FragmentActivity) mActivity, this)
51+
.addConnectionCallbacks(this)
5152
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
5253
.build();
5354

@@ -95,6 +96,9 @@ public void login() {
9596
mActivity.startActivityForResult(signInIntent, GoogleActions.SIGN_IN);
9697
} else {
9798
onConnectedAction = GoogleActions.SIGN_IN;
99+
if (!mGoogleApiClient.isConnecting()) {
100+
mGoogleApiClient.connect();
101+
}
98102
}
99103
}
100104
private void revokeAccess() {

0 commit comments

Comments
 (0)