"Sync is Off" showing after running the Sync Adapter On Demand using ContentResolver.requestSync() function

406 views Asked by At

I am trying to implement Contact Sync Adapter. Its working fine when I do sync operation from the sync option given under corresponding Account. But when I try to call requestSync() first time on button click, onPerformSync() function of SyncAdapter implementation called and executed successfully but still showing Sync is Off under corresponding Account in Sync Settings.

My code for Running Sync adapter on demand is :

Bundle settingsBundle = new Bundle();
                settingsBundle.putBoolean(
                        ContentResolver.SYNC_EXTRAS_MANUAL, true);
                settingsBundle.putBoolean(
                        ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
                /*
                 * Request the sync for the default account, authority, and
                 * manual sync settings
                 */


                ContentResolver.requestSync(mAccount, AUTHORITY, settingsBundle);

So please guide me, is there any way to turn on Sync Setting after running the Sync Adapter On Demand.

1

There are 1 answers

1
mark On BEST ANSWER

I need to set below property before calling requestSync(----) for achieve my goal :

ContentResolver.setSyncAutomatically(mAccount, getString(R.string.content_provider_authority), true);