Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android多个同步适配器项目,如Google帐户?_Android_Sync_Accountmanager_Android Syncadapter - Fatal编程技术网

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

Android多个同步适配器项目,如Google帐户?,android,sync,accountmanager,android-syncadapter,Android,Sync,Accountmanager,Android Syncadapter,我目前已将Android应用程序设置为使用Android的AccountManager功能,使用SyncAdapter和经过身份验证的帐户自动执行同步 我只有一个同步适配器正在运行,它可以同步所有内容,但我想将其分离出来,以在不同的时间间隔对不同的内容执行同步 我怎么能像谷歌那样拥有多个同步项目 您只需使用相同的帐户类型定义几个同步适配器即可 清单包含: <service android:exported="true" android:name="com.example.FooSyncAd

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

我只有一个同步适配器正在运行,它可以同步所有内容,但我想将其分离出来,以在不同的时间间隔对不同的内容执行同步

我怎么能像谷歌那样拥有多个同步项目


您只需使用相同的帐户类型定义几个同步适配器即可

清单包含:

<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\u bar

<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
    android:contentAuthority="foo"
    android:accountType="com.example"
    android:allowParallelSyncs="true" />
<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:userVisible=“true”

<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
    android:contentAuthority="foo"
    android:accountType="com.example"
    android:allowParallelSyncs="true" 
    android:userVisible="true"/> // this line does the job of showing up.
//此行用于显示。

谢谢,我以前试过,但您的回答让我注意到您对每个SyncAdapter都有不同的contentAuthority,这说明了问题所在-必须有多个ContentProvider,每个ContentProvider都注册到SyncAdapter xml文件中指定的contentAuthority。非常感谢!如何将标签设置为问题图片中的标签?