自己的 Android 同步适配器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1859241/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:43:53  来源:igfitidea点击:

Own sync adapter for Android?

androidsynchronizationandroid-syncadapter

提问by Seba

The press release of Android 2.0 states that the new release supports sync adapters so that emails and calendars cannot only be synced with gmail and exchange. However, there is no information available online how to write such a sync adapter. Has anyone tried it and some example code available?

Android 2.0 的新闻稿指出,新版本支持同步适配器,因此电子邮件和日历不能只与 gmail 和 exchange 同步。但是,网上没有关于如何编写这样的同步适配器的信息。有没有人试过它并提供一些示例代码?

回答by white_gecko

These two articles by Sam Steele (January 23rd, 2010) are about the implementation of the last.fmsync adapter. Do not miss the second part and the opensource projects that are mentioned at the end of the articles.

Sam Steele 的这两篇文章(2010 年 1 月 23 日)是关于last.fm同步适配器的实现。不要错过第二部分和文章末尾提到的开源项目。

回答by Jerry Brady

This article, http://ericmiles.wordpress.com/2010/09/22/connecting-the-dots-with-android-syncadapter/, is a great, albeit brief overview of creating a sync adapter and getting it to play nice within the Android framework.

这篇文章http://ericmiles.wordpress.com/2010/09/22/connecting-the-dots-with-android-syncadapter/是一篇很棒的文章,尽管简要概述了创建同步适配器并让它发挥良好的作用在安卓框架内。

回答by xtem

回答by Thomas

I'm still learning myself, but this thread should help you understand a little bit.

我仍在学习自己,但是这个线程应该可以帮助您理解一点。

http://www.mail-archive.com/[email protected]/msg64769.html

http://www.mail-archive.com/[email protected]/msg64769.html

回答by JJD

The article of Kyle Miller(March 10, 2012) summarizes how to get started with the SampleSyncAdapter project contained in the SDK samples. He describes how you can add an account for the app in the system settings of your phone. Basically, he explains how the classes AuthenticationService, Authenticatorand AuthenticatorActivityare used to handle the server authentication using a token. At the end of the article are some words about authenticator.xml, syncadapter.xmland contacts.xml.

Kyle Miller文章(2012 年 3 月 10 日)总结了如何开始使用 SDK 示例中包含的 SampleSyncAdapter 项目。他介绍了如何在手机的系统设置中为该应用程序添加帐户。基本上,他解释了如何类AuthenticationServiceAuthenticator以及AuthenticatorActivity用于使用令牌来处理服务器认证。在文章的末尾是一些关于authenticator.xml,syncadapter.xml和 的词contacts.xml

回答by dimib

I found this browsable source code of the android exchange sync adapter from the android sources:

我从 android 源代码中找到了这个可浏览的 android 交换同步适配器源代码:

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.4_r2.1/com/android/exchange/adapter/ContactsSyncAdapter.java?av=f

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.4_r2.1/com/android/exchange/adapter/ContactsSyncAdapter.java?av= F

These where not included, when I manually checked out the android sources at http://source.android.com. Maybe someone can find the appropriate sources of the original google calendar/contact sync adapter? (not just the MS exchange ones)

当我在http://source.android.com 上手动查看 android 源代码时,这些不包括在内。也许有人可以找到原始谷歌日历/联系人同步适配器的适当来源?(不仅仅是 MS 交换的)

Here is a german student research paper I found through google:

这是我通过谷歌找到的德国学生研究论文:

ftp://ftp.informatik.uni-stuttgart.de/pub/library/medoc.ustuttgart_fi/STUD-2348/STUD-2348.pdf

ftp://ftp.informatik.uni-stuttgart.de/pub/library/medoc.ustuttgart_fi/STUD-2348/STUD-2348.pdf

回答by user160231

Here is something that I found

这是我发现的东西

Implements a SyncAdapter for Contacts

为联系人实现 SyncAdapter

Not sure if this is what we need to help us roll our own contacts sync service though.

不确定这是否是我们帮助我们推出自己的联系人同步服务所需要的。