title: Handling Google Play Game Achievements when player isn't logged in
body: <p>I'm using Google's Achievements API for the first time and have found it fairly simple to set-up.  I got it up and running in about an hour, <em>however</em>, one thing I just can't figure out, is how to go about unlocking achievements when the user isn't signed in (or rather storing the fact that achievement <em>x</em> has been unlocked locally so it can actually be unlocked when the user next logs in).</p>
  
  <p>My achievements are unlocking OK if the user is signed in.</p>
  
  <p>Initially, when I was testing this without being logged in, I was getting a '<strong><em>googleAPIClient is not connected yet</em></strong>' error popping up in my LogCat.</p>
  
  <p>So I did something like this:</p>
  
  <pre><code>public void unlockAchievements(){
      if (isSignedIn()){        
          Games.Achievements.unlock(getApiClient(), myAchievementID);
      }
  }
  </code></pre>
  
  <p>This obviously avoids the crash, but (again, obviously), doesn't unlock the achievement if the user isn't yet signed in.</p>
  
  <p>Is there an 'official' way the handle this (I can't seem to find any mention of this in the doccumentation - although I may have missed it).</p>
  
  <p>If there isn't, what would be a good way to do this?</p>
  
  <p>I could do something like:</p>
  
  <pre><code>if (score&gt;1000){  
      score1000Achievement = true;  //Save this to SharedPreferences
  }
  </code></pre>
  
  <p>And then later, do this:</p>
  
  <pre><code>onSignInSucceeded(){
      if (score1000Achievement){
          Games.Achievements.unlock(getApiClient(), myAchievementID);  
      }
  }
  </code></pre>
  
  <p>However, this would run and attempt an unlock at <strong>every</strong> login, which, with multiple achievements and multiple users, would surely increase my API calls and therefore eat into my quota unnecessarily?</p>
  
  <p>Grateful for any advise</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Just found this on an Android Developers Site</p>
  
  <blockquote>
    <p>An unlocked achievement means that the player has successfully earned the achievement. An achievement can be unlocked offline. When the game comes online, it syncs with the Google Play games services to update the achievement's unlocked state.</p>
  </blockquote>
  
  <p>However, there seems to be no further mention of it and no example of how this is accomplished.</p>