Inability to enable GoogleApiClient in AppCompatActivity

Attempting to perform basic setup according to Google guidelines:

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

The second "this" for OnConnectionFailedListener is not working

Invalid 2nd argument type.

Found: ".... HomeScreen", required: "com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener" less ...

enableAutoManage (FragmentActivity, com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener) in Builder cannot be applied to (HomeScreen, .... HomeScreen)

So, I tested this by changing the class from AppCompatActivity to FragmentActivity, and it worked fine.

I'm not sure how to implement a listener for manual satisfaction, and since AppCompatActivity extends FragmentActivity, I'm very confused about what happens in this case to debug it.

In addition, the class has AppCompatActivity dependencies, so I'm not sure how to get started setting up the API.

This follows the FacebookSDK setup work I was working with, so I kind of hoped that they had a similarly functioning “button” and that it could work in a similar way, but the equivalent SDK initialization seems to be nothing at this stage.

Any direction would be welcome.

In addition, for clarification, I only need to be able to authenticate with Google, where, since marking this message using the API assumes that it is intended for Google Play services, that goes beyond what I need, so if I can just ax of this part, it will be good.

+5
source share
1 answer
 mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this ,(OnConnectionFailedListener) this ) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); 

Just adding what worked for me

+11
source

Source: https://habr.com/ru/post/1242679/


All Articles