Jam*_*win 11 android sync accountmanager android-syncadapter
我目前将Android应用设置为使用Android的AccountManager功能,使用SyncAdapter和经过身份验证的帐户自动执行同步.
我只有一个同步适配器运行,它同步所有内容,但我想将其分开,以不同的间隔执行不同内容的同步.
我如何拥有像Google这样的多个同步项?

rds*_*rds 24
您只需使用相同的帐户类型定义多个同步适配器.
清单包含:
<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>
Run Code Online (Sandbox Code Playgroud)
而且syncdataper_foo是
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="foo"
android:accountType="com.example"
android:allowParallelSyncs="true" />
Run Code Online (Sandbox Code Playgroud)
而且syncdataper_bar是
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="bar"
android:accountType="com.example"
android:allowParallelSyncs="true" />
Run Code Online (Sandbox Code Playgroud)
请注意,对于帐户类型"com.google",同步适配器甚至由不同的应用程序(云端硬盘,文档,表格,Gmail,日历等)提供.
| 归档时间: |
|
| 查看次数: |
2947 次 |
| 最近记录: |