issue in app open with fileObserver

2019-08-01 05:15发布

问题:

String path = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_PICTURES+ File.separator + "Screenshots";
FileObserver fileObserver = new FileObserver(path, FileObserver.CREATE) {
    @Override
    public void onEvent(int event, String path) {
        Intent mIntent = new Intent(MainActivity.this,MainActivity.class);
        mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        getApplicationContext().startActivity(mIntent);
    }
};
fileObserver.startWatching();