如果Android存储空间用完了,为什么同步适配器不起作用 [英] Why does the sync adapter won't work if android storage space running out

查看:65
本文介绍了如果Android存储空间用完了,为什么同步适配器不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的android应用程序中,我已经配置了使用同步适配器的定期同步功能,并且可以正常工作,除非android的存储空间用完了.如果我删除了一些文件并释放了空间,那么同步将开始工作.只是将数据从我的设备同步到远程服务器,所以同步时不需要设备中的额外空间.那么android同步适配器为什么需要一些空间才能工作.我注意到的是,即使设备中有2%的可用内存.Similary我发现,如果使用了98%的设备内存,则android设备中的gmail应用程序也将无法正常工作.Gmail将显示无法同步的消息,并且不会同步,并且如果设备内存已满,将收到任何消息.如果内存已满,有什么方法可以启动同步适配器?如果没有,我该如何通知我的应用程序用户?

In my android application I have configured a periodic syncing using sync adapter, and its working fine except if the android storage space is running out.If i deleted some files and free up space then sync will start to work.Actually I am just syncing data from my device to the remote server,so there is no need for extra space in device while syncing.So why does the android sync adapter demand some space to work.What I noticed is the sync adapter won't work even if there is a 2% free memory is in the device.Similary I found that the gmail application in android device also won't work if 98 percentage of device memory is used.Gmail will show a couldn't sync message and will not sync and receive any message if device memory is full.So is there any way to start the sync adapter if the memory is full? If not then how can i notify my application users about this fact?

推荐答案

这是标准的AOSP/Android行为.

This is standard AOSP/Android behaviour.

  1. SyncManager监听 Intent.ACTION_DEVICE_STORAGE_LOW 设备存储空间不足和它还会监听 Intent.ACTION_DEVICE_STORAGE_OK 目的是为了确定存储已恢复正常,并且

    It also listens to the Intent.ACTION_DEVICE_STORAGE_OK intent in order to find out that the storage is back to normal and reschedules the syncs

    之所以这样做,可能是因为它由SyncStorageEngine备份,该存储将各种信息存储在

    It does this probably because it is backed up by the SyncStorageEngine that stores various information in XML files

    尽管这个答案很晚,但是如果您想通知用户,则在Android Oreo及更低版本上,您可以收听相同的广播并通知他们.从Android Oreo开始,它变得有些棘手,因为建议使用Context.getCacheDir()来管理您的缓存空间.请参阅此答案以获取更多详细信息

    Though this answer is late, if you want to notify your users, On Android Oreo and below you can listen to the same broadcasts and notify them. From Android Oreo it gets a bit more tricky as the recommendation is to use the Context.getCacheDir() in order to manage your cache space. Refer to this answer for more details

    这篇关于如果Android存储空间用完了,为什么同步适配器不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆