Search code examples
androidandroid-serviceandroid-syncadapterandroid-service-bindingsyncservices

Bind SyncAdapter service to Activity


I'm currently working with a SyncAdapter that syncs data every 15 minutes. Is it possible to bind that Service to the Activity so I can show the user what the currenty sync status is?

I read in the documentation about IPC between services and activities that you can communicate with Messengers and Handlers. But I can't return a mMessenger.getBinder() in my SyncService onBind method because I have to return the syncAdapter.getSyncAdapterBinder() because of the SyncAdapter.


Solution

  • You can return a different IBinder, depending on the action that was set for the Intent. Check out my response to Android SyncAdapter: how to get notified of specific sync happened