Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 游戏应用程序不断尝试连接到Google Play服务而不放弃_Java_Android - Fatal编程技术网

Java 游戏应用程序不断尝试连接到Google Play服务而不放弃

Java 游戏应用程序不断尝试连接到Google Play服务而不放弃,java,android,Java,Android,在没有数据访问的情况下,我的游戏应用程序有时会通过不断尝试连接google play服务而锁定,但最终不会放弃 循环的错误代码需要签名。游戏确实加载,但在持续重新启动的google play连接尝试屏幕(带有旋转加载图标)上,对游戏的访问被阻止 以下是重复引用的代码: protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestC

在没有数据访问的情况下,我的游戏应用程序有时会通过不断尝试连接google play服务而锁定,但最终不会放弃

循环的错误代码需要签名。游戏确实加载,但在持续重新启动的google play连接尝试屏幕(带有旋转加载图标)上,对游戏的访问被阻止

以下是重复引用的代码:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case REQUEST_CODE_RESOLUTION://same constant as R_SIGN_IN_FAILED
           retryConnecting();
           break;
    }
}

.....

private void retryConnecting() {
    mIsInResolution = false;
    if (!mGoogleApiClient.isConnecting()) {
        mGoogleApiClient.connect();
    }
}
我相信这是来自平凡的驱动器示例代码。不幸的是,不同google play服务功能的每个代码示例都以不同的方式实现basegameutils库,包括仅用于连接的简单活动示例代码

我还怀疑示例代码中您定义的常量:

protected static final int REQUEST_CODE_RESOLUTION = 1;
与以下的“GameHelperUtils”类常量冲突:

public static final int R_SIGN_IN_FAILED = 1;

所以onActivityResult中的“case REQUEST\u CODE\u RESOLUTION:”实际上是“case R\u SIGN\u in\u FAILED:”。

我认为您应该在onConnectionFailed()方法中处理请求代码解析,如下所示

public void onConnectionFailed(ConnectionResult result) {
  if (!mIntentInProgress && result.hasResolution()) {
    try {
      mIntentInProgress = true;
      startIntentSenderForResult(result.getResolution().getIntentSender(),
          RC_SIGN_IN, null, 0, 0, 0);
    } catch (SendIntentException e) {
      // The intent was canceled before it was sent.  Return to the default
      // state and attempt to connect to get an updated ConnectionResult.
      mIntentInProgress = false;
      mGoogleApiClient.connect();
    }
  }
}
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
  if (requestCode == RC_SIGN_IN) {
    mIntentInProgress = false;

    if (!mGoogleApiClient.isConnecting()) {
      mGoogleApiClient.connect();
    }
  }
}
活动结果如下

public void onConnectionFailed(ConnectionResult result) {
  if (!mIntentInProgress && result.hasResolution()) {
    try {
      mIntentInProgress = true;
      startIntentSenderForResult(result.getResolution().getIntentSender(),
          RC_SIGN_IN, null, 0, 0, 0);
    } catch (SendIntentException e) {
      // The intent was canceled before it was sent.  Return to the default
      // state and attempt to connect to get an updated ConnectionResult.
      mIntentInProgress = false;
      mGoogleApiClient.connect();
    }
  }
}
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
  if (requestCode == RC_SIGN_IN) {
    mIntentInProgress = false;

    if (!mGoogleApiClient.isConnecting()) {
      mGoogleApiClient.connect();
    }
  }
}

我认为您应该在onConnectionFailed()方法中处理请求代码解析,如下所示

public void onConnectionFailed(ConnectionResult result) {
  if (!mIntentInProgress && result.hasResolution()) {
    try {
      mIntentInProgress = true;
      startIntentSenderForResult(result.getResolution().getIntentSender(),
          RC_SIGN_IN, null, 0, 0, 0);
    } catch (SendIntentException e) {
      // The intent was canceled before it was sent.  Return to the default
      // state and attempt to connect to get an updated ConnectionResult.
      mIntentInProgress = false;
      mGoogleApiClient.connect();
    }
  }
}
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
  if (requestCode == RC_SIGN_IN) {
    mIntentInProgress = false;

    if (!mGoogleApiClient.isConnecting()) {
      mGoogleApiClient.connect();
    }
  }
}
活动结果如下

public void onConnectionFailed(ConnectionResult result) {
  if (!mIntentInProgress && result.hasResolution()) {
    try {
      mIntentInProgress = true;
      startIntentSenderForResult(result.getResolution().getIntentSender(),
          RC_SIGN_IN, null, 0, 0, 0);
    } catch (SendIntentException e) {
      // The intent was canceled before it was sent.  Return to the default
      // state and attempt to connect to get an updated ConnectionResult.
      mIntentInProgress = false;
      mGoogleApiClient.connect();
    }
  }
}
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
  if (requestCode == RC_SIGN_IN) {
    mIntentInProgress = false;

    if (!mGoogleApiClient.isConnecting()) {
      mGoogleApiClient.connect();
    }
  }
}

我在这里发现了一个onActivityResult实现,它解决了这个问题和其他问题

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);

// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
    // not handled, so handle it ourselves (here's where you'd
    // perform any handling of activity results not related to in-app
    // billing...
    super.onActivityResult(requestCode, resultCode, data);
}
else {
    Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}

我在这里发现了一个onActivityResult实现,它解决了这个问题和其他问题

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);

// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
    // not handled, so handle it ourselves (here's where you'd
    // perform any handling of activity results not related to in-app
    // billing...
    super.onActivityResult(requestCode, resultCode, data);
}
else {
    Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}