0

この問題に立ち寄ってから長い時間が経ちました.FileObserverのonEventメソッドはトリガーもテストもされておらず、「入力されたメソッド」トーストも表示されていません.

FileObserver fileObserver = new FileObserver(android.os.Environment.getExternalStorageDirectory().toString() + "/Pictures/Screenshots") {
    @Override
    public void onEvent(int event, String path) {

        Toast.makeText(getApplicationContext(), "method entered", Toast.LENGTH_SHORT).show();

        if (event == FileObserver.CREATE) {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(getApplicationContext(), "File created", Toast.LENGTH_SHORT).show();
                }
            });
        }
    }
};

fileObserver.startWatching();

お願い助けて!前もって感謝します。

4

1 に答える 1