android-basic-samples icon indicating copy to clipboard operation
android-basic-samples copied to clipboard

Task result of incrementImmediate does not return the correct unlock status.

Open martin-braun opened this issue 5 years ago • 0 comments

Hi,

I've spotted a bug in AchievementsClient.incrementImmediate.

The documentation states:

This form of the API will attempt to update the user's achievement on the server immediately. The Boolean in a successful response indicates whether the achievement is now unlocked.

However, it always returns false, even when the achievement becomes unlocked. This is my code:

boolean result = false;
boolean unlocked = false;

// In a function:
Games.getAchievementsClient(GoogleSignIn.getLastSignedInAccount(this)).incrementImmediate("123456789", 1).addOnCompleteListener(new OnCompleteListener<Boolean>() {
	@Override
	public void onComplete(@NonNull Task<Boolean> task) {
		if(task.isSuccessful()) {
			result = true;
			unlocked = task.getResult(); // BUG: This is always false, even when the achievement is unlocked now
		} else {
			result = false;
			unlocked = false;
			Exception ex = task.getException();
			Log.d(TAG, "Failed to increment achievement progress: " + (ex != null ? ex.getMessage() : "UNKNOWN"));
		}
	}
});

martin-braun avatar Oct 12 '18 16:10 martin-braun