android - SyncAdapter for detecting changes in device's native contacts list -
I used the content observer to inform about the change in the device's contact list. The problem is that I need to work in the background (when the application is closed as well), then I have used a service for it, but still it dosn't work (unless I Announce the service to work on the foreground - and we do not want to do this).
So I have another solution to use SyncAdapter. I have my own storage solution and I am not using ContentProvider in my application. I also have my own implementation for finding out which contacts have been changed / removed / find out.
The only thing I need to know when it is informed about this and about it.
Do I need a stub content provider to achieve this? Is it enough to declare com.android.contacts as the right to sync adapter?
I already have to configure them ...
Thank you some help with thanks! Rotum
o.k. So I finally discovered things.
To achieve this, (Notifications about the device are only being reported about changes), you do not need a stub content provider. Announce a sync adapter with Sync Adapter Service: Android: In the XML declaration of SyncAdapter, use ContactsContract.AUTHORITY which means contentAuthority = "com.android.contacts"
and set an automatic sync: ContentResolver. SetSyncAutomatically (accounts, ContactsContract.AUTHORITY, true);
Remember that your onPerformSync method will not be called in your SyncAdapter implementation, the system "waits" for the best time to make those syncing, from my experience in any way It took ~ 40 seconds.
Comments
Post a Comment