Android多个同步适配器项目,如Google帐户?

Android多个同步适配器项目,如Google帐户?,第1张

概述我目前将Android应用设置为使用Android的AccountManager功能,使用SyncAdapter和经过身份验证的帐户自动执行同步.我只有一个同步适配器运行,它同步所有内容,但我想将其分开,以不同的间隔执行不同内容的同步.我如何拥有像Google这样的多个同步项?解决方法:您只需使用相同的帐户类型

我目前将Android应用设置为使用AndroID的AccountManager功能,使用SyncAdapter和经过身份验证的帐户自动执行同步.

我只有一个同步适配器运行,它同步所有内容,但我想将其分开,以不同的间隔执行不同内容的同步.

我如何拥有像Google这样的多个同步项?

解决方法:

您只需使用相同的帐户类型定义多个同步适配器.

清单包含:

<service androID:exported="true" androID:name="com.example.FooSyncAdapterService">  <intent-filter>    <action androID:name="androID.content.SyncAdapter" />  </intent-filter>  <Meta-data androID:name="androID.content.SyncAdapter" androID:resource="@xml/syncadapter_foo" /></service><service androID:exported="true" androID:name="com.example.barSyncAdapterService">  <intent-filter>    <action androID:name="androID.content.SyncAdapter" />  </intent-filter>  <Meta-data androID:name="androID.content.SyncAdapter" androID:resource="@xml/syncadapter_bar" /></service>

而syncdataper_foo是

<sync-adapter xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:contentAuthority="foo"    androID:accountType="com.example"    androID:allowParallelSyncs="true" />

而syncdataper_bar是

<sync-adapter xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:contentAuthority="bar"    androID:accountType="com.example"    androID:allowParallelSyncs="true" />

请注意,对于帐户类型“com.Google”,同步适配器甚至由不同的应用程序(云端硬盘,文档,表格,Gmail,日历等)提供.

总结

以上是内存溢出为你收集整理的Android多个同步适配器项目,如Google帐户?全部内容,希望文章能够帮你解决Android多个同步适配器项目,如Google帐户?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1098569.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存