Android:在MediaStore.Files.getContentUri()中检测文件更改时,ContentObserver不起作用,而不是MediaStore.Audio.Media.EXTERNAL_CONTENT_URI

时间:2019-01-30 03:56:52

标签: android

contentResolver.registerContentObserver(MediaStore.Files.getContentUri("external"), false, new ContentObserver(new Handler())
{
    @Override
    public boolean deliverSelfNotifications()
    {
        Log.d("TAG", "deliverSelfNotifications");
        return super.deliverSelfNotifications();
    }

    @Override
    public void onChange(boolean selfChange)
    {
        super.onChange(selfChange);
        Log.d("TAG", "onChange");
    }

    @Override
    public void onChange(boolean selfChange, Uri uri)
    {
        super.onChange(selfChange, uri);
        Log.d("TAG", "onChange " + uri.toString());
    }
});

当我删除文件时, onChange()会调用,但添加文件后将无法正常工作。

非常感谢您的帮助!

0 个答案:

没有答案