以编程方式启用自动同步

问题描述 投票:0回答:1

我想以编程方式在我的应用程序的帐户设置中启用自动同步。我已经设置了SyncAdapter,并在清单中对其进行了声明,然后添加了帐户,然后尝试执行此操作:

ContentResolver.setSyncAutomatically(account, authority, true);
ContentResolver.setMasterSyncAutomatically(true);

但是它不起作用。 SE上存在相同的问题:

但是它们太旧了,我发现其中我需要使用ContentResolver.setMasterSyncAutomatically(true),但在我的Android 7,Android 9上无法使用。

Auto sync is not enabled

android synchronization android-syncadapter android-account
1个回答
0
投票

问题出在authority中的ContentResolver.setSyncAutomatically(account, authority, true);字符串参数中,联系人同步需要为com.android.contacts

© www.soinside.com 2019 - 2024. All rights reserved.