Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using SyncAdapter without creating an account

My app allows people to use and manage their data regardless they're logged in. Though, as I uniquely identify each device, I want to sync data from my anonymous users (not logged ones) as well. So, I was wondering if it is a good practice to create an anonymous account in this case, since SyncAdapters only work with accounts.

Should I create an account for my anonymous users or should I sync their data with threads/AsyncTasks/Loaders? In particular, is there any way to make ContentResolver.requestSync() work without the need of an account?

like image 429
Flávio Faria Avatar asked Aug 30 '12 21:08

Flávio Faria


1 Answers

Using the SyncAdapter/AccountManager in Android is frankly more trouble than it's worth. That specific pattern is best used only when you expect a large number of other applications to want to share your account data (e.g. Twitter or Facebook).

I'd suggest you simply write your own background Service implementation to do your syncing. You can use an AlarmManager to notify the service to sync periodically. Otherwise, you can simply sync when the user opens your application using a basic AsyncTask.

like image 56
twaddington Avatar answered Nov 20 '22 02:11

twaddington