Skip to content

Instantly share code, notes, and snippets.

@Axxiss
Created May 21, 2012 13:31
Show Gist options
  • Save Axxiss/2762338 to your computer and use it in GitHub Desktop.
Save Axxiss/2762338 to your computer and use it in GitHub Desktop.
Sync service
public class SyncService extends Service {
/** Lock to synchronize access to SyncAdapter*/
private static final Object syncLock = new Object();
/** SyncAdapter used to sync data with server */
private static SyncAdapter sSyncAdapter = null;
@Override
public void onCreate(){
synchronized(syncLock)
{
if(sSyncAdapter == null)
sSyncAdapter = new SyncAdapter(getApplicationContext(), true);
}
}
@Override
public IBinder onBind(Intent arg0) {
return sSyncAdapter.getSyncAdapterBinder();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment