[英]Toggle on auto-sync progarammatically in Android
可能是大约2-4年前问这个问题。还是不满意。我的问题是:“如何以编程方式打开/关闭自动同步”。我不希望任何特定的数据同步。只想知道这是否可能以编程方式启用或禁用自动同步? 如果可能的话,如何? 谁能给我例子?
在Android屏幕上显示如下:
ContentResolver.setSyncAutomatically(account, authority, true);
的用途是什么ContentResolver.setSyncAutomatically(account, authority, true);
在自动同步中?
提前致谢。
我猜您在谈论gmail自动同步电子邮件,对吗? 一种方法是setMasterSyncAutomatically()(ContentResolver),适用于所有帐户(和提供程序)。 如果将此设置为off / false,则可以禁用所有同步。
这就是我们从android documentation获得的 。
public static void setMasterSyncAutomatically (boolean sync)
Added in API level 5
Sets the master auto-sync setting that applies to all the providers and accounts. If this is false then the per-provider auto-sync setting is ignored.
This method requires the caller to hold the permission WRITE_SYNC_SETTINGS.
Parameters
sync the master auto-sync setting that applies to all the providers and accounts
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.