【发布时间】:2016-11-15 16:33:38
【问题描述】:
我有一个简单的游戏,有一个排行榜按钮,它显示玩家的最高分,在发布这个问题之前,我已经确定了以下几点:
- SHA1 指纹。
- API 已启用。
- 正确的包。
- 正确的应用 ID。
- 已导入并添加了 Google Play 服务库。
- 配置文件已导入。
- Admob、Analytics 和崩溃报告运行良好。
- GET ACCOUNTS 已经添加,还是一样。
我的问题是,没有显示帐户选择器/选择器,甚至没有登录,我收到以下错误:
ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{fbd982b: android.os.BinderProxy@b3d396d}, message=null
代码:
public class MainActivity extends AppCompatActivity implements
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
ImageButton mLeaderBoard;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
mLeaderBoard = (ImageButton) findViewById(R.id.leaderboard);
mLeaderBoard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ShowBoard();
}
});
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API)
.addScope(Games.SCOPE_GAMES)
.addScope(SCOPE_PLUS_PROFILE)
.build();
}
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override
protected void onStop() {
super.onStop();
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}
}
private void ShowBoard() {
if(!isSignedIn()){
mGoogleApiClient.connect();
}
mGoogleApiClient.connect();
if(isSignedIn())
startActivityForResult(Games.Leaderboards.getLeaderboardIntent(mGoogleApiClient,
LEADERBOARD_TOP_SCORE_ID), 1);
else
Toast.makeText(this, getResources().getString(R.string.leaderboard_not_available), Toast.LENGTH_LONG).show();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == 1) {
Log.i("GoogleSignInApi","Result: " + resultCode + " - Data: " + data.getData());
if (resultCode == RESULT_OK) {
}
}
}
@Override
public void onConnected(Bundle bundle) {
}
@Override
public void onConnectionSuspended(int i) {
mGoogleApiClient.connect();
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.i("GoogleSignInApi","Problem: " + connectionResult.getErrorMessage() + " - Test: " + connectionResult.toString());
}
}
【问题讨论】:
-
游戏已经发布了,已经有5个小时了。
标签: android google-play-services google-play-games