简体   繁体   English

同步适配器在小米手机中不起作用

[英]Sync adapter not working in xiaomi mobile

I created a sync adapter to sync data from android mobile to a server at interval.我创建了一个同步适配器,以将数据从 android mobile 每隔一段时间同步到服务器。 The adapter is working perfectly in all android devices except Redmi note 4. Tried with changing different different settings in Redmi note 4 but of no use.该适配器在除 Redmi note 4 之外的所有 android 设备上都可以完美运行。尝试在 Redmi note 4 中更改不同的不同设置,但没有用。

What could be the reason for this?这可能是什么原因?

You could remove the security app.您可以删除安全应用程序。 Although it would require you to root.虽然它需要你root。 Here's some further reading . 这里有一些进一步的阅读

Following code is typical registering code syncAdaptor Service以下代码是典型的注册代码syncAdaptor Service

     <service
            android:name="com.example.android.datasync.SyncService"
            android:exported="true"
            android:process=":sync">
        <intent-filter>
            <action android:name="android.content.SyncAdapter"/>
        </intent-filter>
        <meta-data android:name="android.content.SyncAdapter"
                android:resource="@xml/syncadapter" />
     </service>

The attribute android:process=":sync" tells the system to run the Service in a global shared process named sync.属性android:process=":sync"告诉系统在名为 sync 的全局共享进程中运行服务。 If you have multiple sync adapters in your app they can share this process, which reduces overhead.如果您的应用程序中有多个同步适配器,它们可以共享此过程,从而减少开销。

if you remove this attribute from Service tag, that will work on Xiami phone如果您从服务标签中删除此属性,这将适用于虾米手机

The Xiaomi's Security app blocking the service.小米的安全应用程序阻止了该服务。 Check it, and enable the service running.检查它,并启用服务运行。 But I don't know the real solution但我不知道真正的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM