Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- }
- });
- }
- }
Add Comment
Please, Sign In to add comment