如何通过Android的API更改同步设置? [英] How to change sync settings through Android API?

查看:138
本文介绍了如何通过Android的API更改同步设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法更改Gmail帐户的同步设置编程方式与Android应用?举例来说,我想启用/禁用从我的应用程序Gmail帐户的同步,无需用户做任何事。

Is there a way to change the sync settings of a Gmail account programmatically with an Android app? For instance, I'd like to enable/disable syncing of a Gmail account from my app, without the user having to do anything.

我看了一下 的AccountManager ,但似乎并没有被找对地方了。

I took a look at AccountManager, but that doesn't seem to be the right place to look.

推荐答案

您可以通过API使用更改 ContentResolver.setSyncAutomatically(客户账户,串权威,布尔同步)。你需要得到一个处理账户问题(通常通过的AccountManager类......),你会需要查找内容权威字符串。后者可以从 android.Provider.xxxContract 获得(ContactsContract例如...)

You can change it through the API using ContentResolver.setSyncAutomatically(Account account, String authority, boolean sync). You need to get a handle to the account in question (usually through the AccountManager class...) and you'll need to lookup the content authority string. The latter you can get from android.Provider.xxxContract (ContactsContract for example...)

这篇关于如何通过Android的API更改同步设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆