我目前已将 Android 应用程序设置为使用 Android 的 AccountManager 功能,使用 SyncAdapter 和经过身份验证的帐户自动执行同步。
我只运行 1 个同步适配器,用于同步所有内容,但我想将其分开,以便以不同的时间间隔对不同的内容执行同步。
如何像 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>
And syncdataper_foo
is
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="foo"
android:accountType="com.example"
android:allowParallelSyncs="true" />
And syncdataper_bar
is
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="bar"
android:accountType="com.example"
android:allowParallelSyncs="true" />
请注意,在帐户类型“com.google”的情况下,同步适配器甚至由不同的应用程序(云端硬盘、文档、表格、Gmail、日历等)提供。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)