Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sync Adapter without Account

I need to fetch some data over the cloud from my app. I've watched the google IO video on RESTful android apps @ http://www.youtube.com/watch?v=xHXn3Kg2IQE&t=43m58s It recommends in the final slides to use a SyncAdapter to integrate with the Android System.

Later I learned that one has to use an Account to implement SyncAdapter. My app does not use an account. Users can freely download data without registration. Can I still use SyncAdapter? Is there a stock dummy account that I could use?

Edit: I do have a content provider for my app so that's not a problem

Edit2: I've just looked at the Weather and Stock apps under Settings -> Accounts & Sync. You can see that they allow syncing, but don't have a remove account button. On the other hand, Google, Facebook and Skype apps allow syncing PLUS they have a remove account button. This means Weather and Stock don't use accounts, whereas Google, Facebook and Skype do.

The tutorials I found @ http://ericmiles.wordpress.com/2010/09/22/connecting-the-dots-with-android-syncadapter/ and @ http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-1/ say that one MUST have an account to use Sync Adapter. :S ???

like image 293
siamii Avatar asked Feb 28 '11 18:02

siamii


People also ask

What is SyncAdapter in Android?

The sync adapter component in your app encapsulates the code for the tasks that transfer data between the device and a server. Based on the scheduling and triggers you provide in your app, the sync adapter framework runs the code in the sync adapter component.


1 Answers

As the Android Developer docs say

Even if your app doesn't use accounts, you still need to provide an authenticator component. If you don't use accounts or server login, the information handled by the authenticator is ignored, so you can provide an authenticator component that contains stub method implementations. You also need to provide a bound Service that allows the sync adapter framework to call the authenticator's methods.

There is an entire article on Creating a Stub Authenticator. I realise that this question is old and an answer was accepted long ago, but I felt that a recent addition to the official docs should be included here.

like image 78
nindalf Avatar answered Oct 02 '22 09:10

nindalf