title: SyncAdapter not getting called on "Network tickle"
body: <p><strong>Overview</strong></p>
  
  <p>I follwed <a href="http://developer.android.com/training/sync-adapters/creating-authenticator.html">Google's tutorial</a> on using SyncAdapter without using ContentProvider, Authenticator..etc. It works perfectly when I call <code>onPerformSync(...)</code> when I need to do an "upload" to the server via de SyncAdapter. </p>
  
  <p>Now, as you can imagine, I need to do downloads from the server as well (yes I understand that it would be better to use Google's Cloud Messaing system, but this is the set up I was given, and I can't change that). For that, instead of doing periodical syncs, I want to make use of the "Network tickle" Android system carries out when there is a network available. For that I state the following:</p>
  
  <pre><code>ContentResolver.setIsSyncable(accounts[0], AUTHORITY, 1);
  ContentResolver.setSyncAutomatically(accounts[0], AUTHORITY, true); 
  </code></pre>
  
  <p>But my SyncAdapter <strong>is just not getting called</strong>. Looking into other stackOverFlow questions, there seem to be a problem if targetting API 10 or below with SyncAdapter and that you must add an account explicitly <strong>before</strong> calling the before methods. So I ended up with this:</p>
  
  <pre><code>AccountManager accountManager = (AccountManager) context.getSystemService(ACCOUNT_SERVICE);
  
      Account[] accounts = accountManager.getAccounts();
      if(accounts.length == 0){ //ADD DUMMY ACCOUNT
          Account newAccount = new Account(ACCOUNT, ACCOUNT_TYPE);
          ContentResolver.setIsSyncable(accounts[0], AUTHORITY, 1);
          ContentResolver.setSyncAutomatically(accounts[0], AUTHORITY, true); 
          accountManager.addAccountExplicitly(newAccount, null, null);
      }else{
           accounts = accountManager.getAccounts();
          ContentResolver.setIsSyncable(accounts[0], AUTHORITY, 1);   
          ContentResolver.setSyncAutomatically(accounts[0], AUTHORITY, true); 
      }
  </code></pre>
  
  <p>Now this code gets executed when the user signs in, or if the application was killed and is started up again. I am wondering, should I call <code>setIsSyncable</code> and <code>setSyncAutomatically</code> only when I add the dummyAccount the very first time?</p>
  
  <p>Also, part of the "goodiness" of the SyncAdapter is that it will keep on making the calls in case of an exception. But I don't quite understand how this goes about, so instead I have this:</p>
  
  <pre><code>private void profileUpdate(){       
  TableAccounts db = TableAccounts.getInstance(getContext());
  boolean isRecordDirty = db.isRecordDirty(signedInUser);   
  
  if(isRecordDirty){
     if(server.upDateUserProfile(signedInUser)){
         db.cleanDirtyRecord(signedInUser);
         turnOffPeriodicSync();
     }else{
         this.turnOnPeriodicSync(this.sync_bundle);   
     }
  }else
       turnOffPeriodicSync();
  
  }
  </code></pre>
  
  <p>As you can see, depending on the result of my upload to the server, I turn on or off a periodic sync. </p>