【问题标题】:How to stop Google Play Games window from popping up if there is no INTERNET如果没有 INTERNET,如何阻止 Google Play 游戏窗口弹出
【发布时间】:2015-09-08 20:27:24
【问题描述】:

我将 Plus.API、Game.API 和 Drive.API 分别用于应用内购买、排行榜和保存游戏设置。

每次我进入游戏时,即使我多次拒绝登录,Google Play 游戏也会不断弹出。如何使 Games.API/Driver.API 仅显示一次登录,并且如果没有 INTERNET 连接停止弹出,直到用户下次启动游戏?

这是我的代码:

//--------------------- Google API INIT
mGoogleApiClient = new GoogleApiClient.Builder(this)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)   //used for Screenshot posting and Google Account for google api services
    .addApi(Games.API).addScope(Games.SCOPE_GAMES)      //user for Leaderboards
    .addApi(Drive.API).addScope(Drive.SCOPE_APPFOLDER)  //used for Game Saving
    .build();


@Override
protected void onStart() {
    super.onStart();
    mGoogleApiClient.connect();
}

@Override
protected void onStop() {
    if (mGoogleApiClient.isConnected()) {
        mGoogleApiClient.disconnect();
    }
    super.onStop();
}

【问题讨论】:

    标签: google-drive-api in-app-purchase in-app-billing google-play-games google-api-client


    【解决方案1】:

    在您的代码中,您使用的是 API 的 .connect() 方法。这将尝试连接到服务以通过 G+ 进行身份验证。如果您希望在用户第一次关闭弹出窗口/按钮时避免这种情况,您必须将其作为首选项设置存储在您的应用程序中并在您的代码中进行管理。

    关于检查连接状态,请查看这里的实现:How to check internet access on Android? InetAddress never times out

    【讨论】:

      猜你喜欢
      • 2014-12-26
      • 1970-01-01
      • 2013-09-27
      • 2015-03-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-17
      • 2015-03-03
      • 2019-01-04
      相关资源
      最近更新 更多