如何登出Google Play游戏?

时间:2019-01-25 16:28:09

标签: java android login logout google-play-games

我可以登录Google Play游戏,但无法注销。出现以下错误。 未将GoogleApiClient配置为使用Plus.API api。

这是我的密码;

 public void Glogin(View view) {

    //HERE LOGIN
    if (loginout==0)
    {
    apiClient = new GoogleApiClient.Builder(this)
            .addApi(Games.API)
            .addScope(Games.SCOPE_GAMES)
            .enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() {
                @Override
                public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
                    Log.e("HATA", "Google Play Oyun servisine bağlanamadı.Lütfen bağlantınızı kontrol ediniz.");
                    finish();
                }
            }).build();
    btn_gLoginout.setBackgroundResource(R.drawable.logout);
    loginout++;
    }
    //LOGOUT
    else if(loginout==1){
        if (apiClient.isConnected()) {
            Plus.AccountApi.clearDefaultAccount(apiClient);
            apiClient.disconnect();
            apiClient.connect();
            Toast.makeText(this, "Google hesabınızdan çıkış yapıldı.", Toast.LENGTH_SHORT).show();
            btn_gLoginout.setBackgroundResource(R.drawable.login);
            loginout=0;
        }
        }
    }

0 个答案:

没有答案