Awesome! Glad you got that sorted. Here's another one for you:
While I was thinking about the stupid error I get when trying to download achievements if not signed in (it's a signature mismatch for the onAchievementsLoaded callback), I thought I would go take another look at the code in the wrapper. In doing so, I found the cause of the mismatch error. Here's the code as it was:
@Hide
public void onAchievementsLoaded(int status, AchievementBuffer arg1) {
List list1 = new List();
if (status == GamesClient.STATUS_OK) {
list1.Initialize();
for (Achievement ach: arg1){
AchievementWrapper aw = new AchievementWrapper(ach);
//Toast.makeText(mBA.context, "Loading " + aw.getName(), Toast.LENGTH_SHORT).show();
list1.Add(aw);
}
//Toast.makeText(mBA.context, "onAchievementsLoaded: ", Toast.LENGTH_SHORT).show();
mBA.raiseEvent(this, eventName + "_onachievementsloaded", list1);
return;
}
list1 = null;
mBA.raiseEvent(this, eventName + "_onachievementsloaded", (Object[]) null);
}
(Note the last 2 lines)
And here's what I changed it to:
@Hide
public void onAchievementsLoaded(int status, AchievementBuffer arg1) {
List list1 = new List();
list1.Initialize();
if (status == GamesClient.STATUS_OK) {
for (Achievement ach: arg1){
AchievementWrapper aw = new AchievementWrapper(ach);
//Toast.makeText(mBA.context, "Loading " + aw.getName(), Toast.LENGTH_SHORT).show();
list1.Add(aw);
}
//Toast.makeText(mBA.context, "onAchievementsLoaded: ", Toast.LENGTH_SHORT).show();
mBA.raiseEvent(this, eventName + "_onachievementsloaded", list1);
return;
}
list1.Add("ERROR");
mBA.raiseEvent(this, eventName + "_onachievementsloaded", list1);
}
It appears that the way it was written was the cause of the signature mismatch - I guess because when the load failed, it was sending a null object instead of the initialized list that the onAchievementsLoaded callback sub was expecting in B4A. My fix may not be the correct way to address this (I admit that my Java skills are somewhat lacking), however it does work. In my B4A code, I simply do this:
Sub GGS_OnAchievementsLoaded(listAchievements As List)
Try
If listAchievements.Get(0) = "ERROR" Then
ToastMessageShow("Can't load achievements.", False)
Else
gAL = listAchievements
End If
Catch
Send_Error_Report("GGS_onAchievementsLoaded", LastException.Message & CRLF & "Trace: " & Ex.StackTrace)
End Try
End Sub
May be a bit crude, but it works...
- Colin.