问题描述
|
好的,这很简单:我有一个FileObserver类,用于观察带有音乐的文件夹。因此,我实现了onEvent和所有这些东西,但是当我使用文件管理器将文件移动或粘贴到该文件夹时,而不是获取FileObserver.MOVED_TO或FileObserver.CREATE,我得到的是奇怪的事件,其编号为1073741656,没有记录在:
http://developer.android.com/reference/android/os/FileObserver.html
那么,如何获得这些特定事件,例如删除,移动,创建和粘贴?
[编辑]
这是代码:
private class MusicsFileObserver extends FileObserver {
public MusicsFileObserver(String root) {
super(root);
if (!root.endsWith(File.separator)) {
root += File.separator;
}
}
@SuppressWarnings(\"unused\")
public void close() {
super.finalize();
}
public void onEvent(final int event,String path) {
//here is the problem,if you see the documentation,when a file is moved
//to this directory,event should be equal to FileObserver.MOVED_TO,//a constant value of 128. But when debugging,instead of entering here one time
//with event == 128,this method onEvent is being called 4~5 times with event
//with numbers like 1073741656
if (event != FileObserver.ACCESS || event != FileObserver.OPEN || event != 32768)
runOnUiThread(new Runnable() {
public void run() {
rescanMusics();
}
});
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)