-4

i tried this code in to my project the compiler will show the following error.

this is my code.

Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(new ResultCallback<Status>() { @Override public void onResult(Status status) { } });

and this is my error

cannot be cast to com.google.android.gms.common.api.GoogleApiClient$OnConnectionFailedListener
Sat Siva
  • 9
  • 6

2 Answers2

1
@Override
protected void onStart() {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestEmail()
        .build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
        .build();
mGoogleApiClient.connect();
super.onStart();
}

signout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
  Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
          new ResultCallback<Status>() {
              @Override
              public void onResult(Status status) {
                  // ...
                  Toast.makeText(getApplicationContext(),"Logged Out",Toast.LENGTH_SHORT).show();
                  Intent i=new Intent(getApplicationContext(),MainActivity.class);
                  startActivity(i);
              }
          });
 }
vimal raj
  • 295
  • 1
  • 13
-1

i can understand your problem ...

i think you did not implement GoogleApiClient.OnConnectionFailedListener this listener .. and to include this following function in to your java file like..

@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {

}

thats it..

if you want more information see this following link enter link description here

Manigandan P.S
  • 170
  • 2
  • 11