question

xiledsystems avatar image
xiledsystems asked

Can't retrieve Player object

So I have the SDK setup, and I can unlock achievements, but I can't seem to retrieve them. Before even trying, the Player object is coming back null. This is what I'm doing currently during testing to get the Player object (so I can get the PlayerId): PlayerClient pc = client.getPlayerClient(); AGResponseHandle localplayer = pc.getLocalPlayer(); while (localplayer.getStatus() == AGHandleStatus.WAITING) { try { Thread.sleep(50); } catch (InterruptedException e) { } } RequestPlayerResponse resp = localplayer.getResponse(); Player p = resp.getPlayer(); The above is running in it's own thread, so it's not blocking the UI. The p object is null here. In the RequestPlayerResponse object, it has a responseCode of 24, and errorcode UNRECOVERABLE. Any ideas what I may be doing wrong here? Ryan
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

xiledsystems avatar image
xiledsystems answered
So I got it to work. I was not using the Handles properly. PlayerClient pc = client.getPlayerClient(); AGResponseHandle localplayer = pc.getLocalPlayer(); localplayer.setCallback(new AGResponseCallback () { @Override public void onComplete(RequestPlayerResponse requestPlayerResponse) { if (!requestPlayerResponse.isError()) { Player p = requestPlayerResponse.getPlayer(); } } };
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.