LA_
LA_

Reputation: 20429

How to understand if synchronization was started automatically or manually on android?

I use SyncAdapter in my application. So, synchronization can be either automatic (addPeriodicSync) or started manually (requestSync).

How can I know in the process of synchronization how it was started? Because, in case it is started manually (from app interface), I would like to show Toasts etc.

Upvotes: 1

Views: 541

Answers (2)

jcwenger
jcwenger

Reputation: 11453

Don't Toast to notify your user, except maybe for errors or exceptions. Users already see the circle-arrows "syncing" icon in the Status bar when it's in progress. I've had apps on my phone that Toast me during sync (every time) and it's annoying as hell... Especially because your users might be using a completely different app when your background sync starts and all of a sudden boom, some random Toast pops up telling them sync is in progress, and they think it comes from the active app, causing confusion.

If you want to show users your sync progress, look instead at this Google IO 2010 presentation: Developing Android REST Client Applications (pdf and youtube). It shows you how to put sync state into rows in your database, and update your UI. Much better model, as it gives you per-row granularity for information and only shows up if they're looking right at the data being synced.

Upvotes: 2

LA_
LA_

Reputation: 20429

Looks like usage of extras is the best approach.

Upvotes: 1

Related Questions