【问题标题】:Android FileObserver not calling onEvent in USB mass storage modeAndroid FileObserver 在 USB 大容量存储模式下未调用 onEvent
【发布时间】:2012-04-18 17:59:46
【问题描述】:

我将 FileObserver 挂接到 /mnt/sdcard/X 中的特定目录及其子目录递归。当我从手机本身(比如从 Gallery 应用程序)修改此目录的内容时,我的 FileObserver 的 onEvent() 被正确调用并且一切正常。

当我通过 USB 连接到计算机并切换到大容量存储模式时,通过计算机对同一目录所做的所有更改都不会转换为 FileObserver 的事件。 FileObserver 是否存在不能在 USB 大容量存储中工作的限制?

我尝试了“adb push xx /mnt/sdcard/X/xx”,并且这个更改也被正确记录了。

【问题讨论】:

    标签: android inotify usb-mass-storage fileobserver


    【解决方案1】:

    FileObserver 是否存在不能在 USB 大容量存储中工作的限制?

    当通过 USB 大容量存储 (Android 1.x/2.x) 挂载时,Android 中的

    Nothing 可用于外部存储。外部存储由安装它的操作系统专有。当存储如此挂载时,您将不会收到 FileObserver 事件。

    Android 3.0+ 使用媒体传输协议 (MTP) 而不是 USB 大容量存储,因此 FileObserver 应该可以在较新版本的 Android 上使用外部存储,即使其他操作系统可以访问该存储。

    【讨论】:

    • 好的,知道了。我假设一旦关闭 USB 存储设备就会广播 MEDIA_MOUNTED,对吗?
    • @NarendraAcharya:是的,AFAIK。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多