有时,缺少来自Google Play游戏的接受邀请。目前,我使用的是Google实时多人游戏指南中的代码,并在缺少提示时添加了备份检查以手动加载邀请列表。 如何重现此行为:
private void checkForInvitation()
{
if (mSignedInAccount == null) {
return;
}
Games.getGamesClient(context(), mSignedInAccount)
.getActivationHint()
.addOnSuccessListener(
new OnSuccessListener<Bundle>() {
@Override
public void onSuccess(Bundle bundle) {
if (bundle != null) {
Invitation invitation = bundle.getParcelable(Multiplayer.EXTRA_INVITATION);
if (invitation != null) {
//... do something with the invitation
return;
}
}
checkForInvitationBackup();
}
}).addOnFailureListener(createFailureListener("There was a problem getting the activation hint!"));
}
private void checkForInvitationBackup()
{
if (mInvitationsClient == null) return;
mInvitationsClient.loadInvitations().addOnSuccessListener(new OnSuccessListener<AnnotatedData<InvitationBuffer>>() {
@Override
public void onSuccess(AnnotatedData<InvitationBuffer> invitationBufferAnnotatedData)
{
if (invitationBufferAnnotatedData != null) {
InvitationBuffer invitationBuffer = invitationBufferAnnotatedData.get();
if (invitationBuffer != null) {
if (invitationBuffer.getCount() > 0) {
Invitation invitation = invitationBuffer.get(0);
if (invitation != null) {
//... do something with the invitation
}
}
}
}
}
}).addOnFailureListener(createFailureListener("There was a problem getting the invitation list."));
}
为什么捆绑商品为空,有时却不是?我该如何更好地处理它?</ p>