Question

I have a SyncAdapter, which uses the SyncResult SyncStats to pass information back to the Android SyncManager, during a sync e.g.:

public void onPerformSync(final Account account, Bundle extras, String authority,
   final ContentProviderClient provider, final SyncResult syncResult) {

...

++syncResult.stats.numInserts;
... 

}

It would be useful to have access to these stats in my Activity so that I can display some of them to the user. How can I get access to the SyncResult SyncStats from my Activity when a sync is complete? Is there a way to do this?.

Edit: Or would it be best to do this via normal Service to Activity comms (e.g. AbstractService.send())?

Was it helpful?

Solution

I would send a Broadcast at the end of synchronization with the sync stats you require parsed into broadcasted intent's extras. You can even use a sticky broadcast, but beware of its perils :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top