title: Obtaining Sync Status Information using SyncStatusObserver or by other means?
body: <p>Being specific, I have a 'Droid HTC incredible, Android version 2.2, Baseband 2.15.00.07.28, kernel 2.6.32.17-g9a2fe16, Build 3.26.605.1, Software Number 3.26.605.1</p>
  
  <p>I've got Eclipse and the Android SDK all installed and running OK.  It's nice how I can debug and single step code executing on my Droid in Eclipse.</p>
  
  <p>I have read a number of books and tried all the examples, as practice, and am building on a number of years of software development experience ( > 10 years) in other object oriented languages including C++, just not Java, but I'm picking it up pretty quickly.</p>
  
  <p>I've also downloaded, what I believe is, the version of the source code running on my 'Droid running repo / git, and I've been digging into the FRG83G packages/apps/AccountsAndSyncSettings/src/com/android/settings code.</p>
  
  <p>Now.  I want to write a little app that will let me know when a Sync fails.  The scratch that I'm trying to itch is that after I've made a large amount of changes using the GMail contact interface (for example), and the 'Droid fails to sync them (too many deletes perhaps?).  So when a sync consistently fails, I want to display a notification bar icon to let the me know about this sync failure.  Without an app like this, the first indication that it's been failing is when I notice missing contact information perhaps 2-3 days later.</p>
  
  <p>So, logic would seem to indicate that my little app needs to be a SyncStatusObserver to be informed when a sync action changes status, then obtain SyncStatusInfo on that sync and note which sync failed and when.  From what I can gather, this means implementing a SyncStatusObserver and connect it to the broadcast with call to ContentResolver.addStatusChangeListener.  I've implemented this, and I do see the notification messages.</p>
  
  <p>I believe I understand the object model in that an Account Type has zero to many account authorities, and that each account authority denotes the type of data that is being synced (contacts vs. calendar, etc.).</p>
  
  <p>The SyncStatusObserver's single method, onStatusChanged( final int which ), has the 'int which' parameter, that appears to be trying to indicate which account type or which account authority just changed it's sync status.  I've written and connected this, and am receiving these method invocations, as one would expect, when a type of data has synced.  I've observed this in the Eclipse debugger logging window while my app is executing.</p>
  
  <p>My question is how to do you related the single int which parameter value back to an account type, and / or an account authority?  I'd like to call SyncInfo getCurrentSync() and record the account, the authority and the startTime.  (Why start time?  Don't we really want end time, and end status?)</p>
  
  <p>Searching here on stackoverflow, I find in posting <a href="https://stackoverflow.com/questions/5268536/how-does-one-listen-for-progress-from-android-syncadapter">How does one listen for progress from Android SyncAdapter?</a> that the SyncStatusObserver is pretty useless as it doesn't communicate very much useful information with a single integer parameter.  Oh.  OK.</p>
  
  <p>I guess there's another way to look at this question is this:  On the HTC Incredible, when you are at the home screen and you select Menu -> Settings -> Accounts &amp; sync -> Google (an account listed),  the user interface shows the last time that each account type of the GMail account was successfully synced.  Where is the code that gets this information, as this the same information that I'm after, and I want to get this information after each SyncStatusObserver's onStatusChanged method invocation.</p>
  
  <p>In posting <a href="https://stackoverflow.com/questions/6385279/syncadapter-last-update-date">Syncadapter last update date</a> Which basically states that the last sync date / time is not exposed by the current Droid code. </p>
  
  <p>Is there any other way to obtain the last successful sync date / time for each of the SyncAdators?  I really want to scratch my itch (so to speak).</p>