如何为Google日历构建syncadapter? [英] How to build a syncadapter for the google calendar?

查看:150
本文介绍了如何为Google日历构建syncadapter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为学生构建用于管理大学课程的应用程序。

I'm building an application for students to manage the courses of a university.

现在,我想同步事件(事件具有日期和时间)以及简短说明)和Android的Google日历。

Now I would like to synchronize the events (an event has a date and time and a brief description) with the google calendar of Android.

我看了看Android示例中的samplesync适配器,但我发现它对

I took a look at the samplesync adapter from the Android sample, but I didn't find it very useful for the calendar.

应使用复选框从应用程序的设置中启用和禁用应用程序的同步。

The sync of the app should be enabled and disabled from the settings of the app with a checkbox.

有人有一些有用的示例代码吗?

Does anyone has some sample code that can be useful??

推荐答案


  1. 使用 android.preference.PreferenceActivity 来创建您的首选项页面。

  1. Use android.preference.PreferenceActivity to make your preference page.

确保您的应用更新了该复选框在首选项页面上,将其与系统中的值一起打开。 (该设置可能已在帐户和同步系统控制面板中更改。)使用 ContentResolver.getSyncAutomatically(帐户帐户,字符串授权)来读取系统值

Ensure that your app updates the checkbox on the preference page with the value from the system before it opens. (The setting may have been changed in the Accounts & Sync system control panel.) Use ContentResolver.getSyncAutomatically(Account account, String authority) to read the system value

使用 ContentResolver.setSyncAutomatically(帐户帐户,字符串授权,布尔同步)命令系统匹配PreferenceActivity设置 -

请注意,您无法控制提供商的同步-您可以为帐户/提供商控制同步对。您的应用程序需要保留设置为使用的帐户的副本,以便它可以在这些调用中传递。

Note that you can't control sync on a provider -- you control it for an account/provider pair. Your app will need to keep a copy of the Account it is set to use so it can pass it in these calls.

这篇关于如何为Google日历构建syncadapter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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