Android:如何限制禁用同步

时间:2017-04-07 10:59:15

标签: android synchronization android-syncadapter

在我的Android应用程序中,我使用同步适配器,每1小时将与服务器同步数据。我需要每次都能实现这一点,但在android设置中 - >帐户 - >我的应用程序有一个用户关闭同步功能的选项,有没有办法限制用户通过此方法关闭同步。

1 个答案:

答案 0 :(得分:2)

您可以限制禁用同步。在syncadapter.xml中,只需将android:userVisible设置为false。像这样:

<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
          android:contentAuthority="com.example.android.basicsyncadapter"
          android:accountType="com.example.android.basicsyncadapter.account"
          android:userVisible="false"
          android:supportsUploading="false"
          android:allowParallelSyncs="false"
          android:isAlwaysSyncable="true" />    

如果您将userVisible设为false,则用户无法手动禁用设置中的同步。

相关问题