Questions tagged [android-syncadapter]

An Android service that synchronizes data between an Android device and a server

A SyncAdapter is an Android Service that synchronizes data between an Android device and a backend server. SyncAdapters can be part of an Android program, or can be a standalone entity. SyncAdapters are associated with an Account, which defines a collection of data that belongs to a specific application.

The purpose of a SyncAdapter is to ensure that data is kept consistent on the Android device and a server. When the data is changed on the server, the SyncAdapter must identify that a change has been made, and update the data on the Android device to reflect the change.

The most common type of data that is synchronized using SyncAdapters are your Contacts list. Whenever you add a contact on your phone, the contact is also sent to the Google server and stored within. Similarly, if you add a contact from a different Google service, such as GMail, the SyncAdapter will identify that a contact has been added, and replicate the data onto your Android device.

Any type of data can be synced with a backend server, its only dependent on the type of data that your application is dealing with. Other common data types to be synced in this way are Calendars and To-Do/Task lists.

The reason why SyncAdapters exist is to create a local copy of the data, so that it can be accessed quickly without the need for a data connection. For example, if your contacts are kept synced, then you can access your contacts quickly on your Android device regardless of whether you have data access or not - it's all locally-stored data independent from network requirements.

SyncAdapters will usually send a 'check' message to the server on a periodic basis, say every 30 minutes, to ask whether any changes have been made during this time. This is only a small data exchange, and doesn't consume much network data. Further 'synchronization' steps only occur if the data has changed and needs to be updated on the Android device accordingly.

SyncAdapter Class Reference

606 questions
11
votes
7 answers

SyncAdapter periodicsync() not triggering

I'm trying ty figure out how the syncAdapter works, I used the sampleSync Adapter as an example/starting point and I based my first test on it. The only difference is that I'm not working with the default contacts provider, but that I need one of my…
rpan
  • 111
  • 1
  • 1
  • 3
11
votes
1 answer

SyncAdapter running animation - how to know if SyncAdapter is actively synchronizing

I want to show a ProgressBar in the ActionBar while my SyncAdapter is actively synchronizing content to and from the web. I have tried using the SyncStatusObserver together with ContentProvider.addStatusChangeListener. However, I cannot check if a…
foens
  • 8,642
  • 2
  • 36
  • 48
10
votes
6 answers

SampleSyncAdapter Breakpoints Not Working

I'm using Eclipse to learn how the SampleSyncAdapter example works. I can't get my breakpoints to work. I set a breakpoint in multiple locations but none get hit. For example, AuthenticatorActivity.onCreate() never get's called. Anyone know…
Mitch
  • 1,716
  • 3
  • 25
  • 41
10
votes
2 answers

SyncAdapter: Account created, requestSync OK, but setSyncAutomatically not Working

I just created an Account for my app. The account is visible in settings I set syncable="true" in my XML I can perform a manual sync by pressing the settings -> onPerformSync is called I can perform a "code" sync by calling…
Waza_Be
  • 39,407
  • 49
  • 186
  • 260
10
votes
1 answer

How long do bundles get persisted by SyncManager?

I have an application with a SyncAdapter. Additionally to the normal synchronization I trigger a USER_READ event with which I just pass a Bundle to the adapter without persisting it: Bundle settingsBundle = new…
David Medenjak
  • 33,993
  • 14
  • 106
  • 134
10
votes
1 answer

Android: Listening to contact changes like WhatsApp do

I'm building an App which relies heavily on the user's contacts. I've created an Account and create RawContacts on behalf of this account when needed. And I use SyncAdapter and things are great. But I'm still missing some parts of this…
10
votes
2 answers

How to notify calling Activity when SyncAdapter has finished?

In my Android project I use a custom SyncAdapter which downloads data and stores it in local SQLite database. public class CustomSyncAdapter extends AbstractThreadedSyncAdapter { public CustomSyncAdapter(Context context, boolean autoInitialize)…
10
votes
2 answers

Android OAuth2 Bearer token best practices

This nice tutorial is a very good introduction to account authentication on Android and doing it by utilizing Android's AccountManager. However, I need to create a client app for an OAuth2 API using a Bearer token for authentication. At the time of…
9
votes
2 answers

How do I implement an Account on Android without a SyncAdapter

I am implementing a login system for an Android application utilizing the built-in accounts system (with the AccountManager APIs). All is well and good on Android 2.2+, but on Android 2.1 not including a SyncAdapter causes reboots in the account…
9
votes
2 answers

SyncAdapter not getting called on "Network tickle"

Overview I follwed Google's tutorial on using SyncAdapter without using ContentProvider, Authenticator..etc. It works perfectly when I call onPerformSync(...) when I need to do an "upload" to the server via de SyncAdapter. Now, as you can imagine,…
Chayemor
  • 3,577
  • 4
  • 31
  • 54
9
votes
2 answers

Syncing a REST service with an android app

There's a REST service that I use to populate info in my database, that is later used by my app. I've read several threads on the matter, and now have to decide how I want the sync between the REST service and my DB to work. Think of an app that…
tbkn23
  • 5,205
  • 8
  • 26
  • 46
9
votes
3 answers

Change username and password of android custom account

I have created sync adapter for android that syncs data with my server. I works fine, but now I want to be able to change my username and password without removing and adding the account again. How can I do this? I have a login screen that has edit…
nikmin
  • 1,803
  • 3
  • 28
  • 46
9
votes
3 answers

Syncadapter onPerformSync being called twice the first time

My syncadapter works well, except for one thing. After the user installs the application, my app syncs twice. Later, if I manually sync it in "settings" it syncs just once as expected. It's just the very first run of the app that this…
Bhagwad Jal Park
  • 1,093
  • 1
  • 13
  • 22
9
votes
2 answers

Use SyncAdapter to sync with *local* gmail and facebook app data

For an app I need to develop, I need to be able to sync with both gmail and facebook data using a SyncAdapter. I'm hoping to sync with the local facebook and gmail apps (if available) instead their remote servers. Syncing with the local apps…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
8
votes
3 answers

Android SyncAdapter Callback

I have implemented a SyncAdapter, AccountManager and private ContentProvider along the lines of the SimpleSyncAdapter sample project in the SDK. It is all working well. Now I want to show a message to the user when new rows have been downloaded from…
JosephL
  • 5,952
  • 1
  • 28
  • 25
1 2
3
40 41