这是我的 FileObserver 代码:
private void updatecheck() {
// Email sync loop
mHandler.post(new Runnable() {
@Override
public void run() {
if (Looper.myLooper() == null) {
Looper.prepare();
}
FileObserver observerGAD7 = new FileObserver(String.valueOf(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS + "/GAD7_Client_Responses.db"))) {
@Override
public void onEvent(int event, String path) {
if ((FileObserver.MODIFY & event)!=0) {
System.out.println("GAD7 file event");
//TODO EMAIL GAD7 DATABASE AUTOMATICALLY
}
}
};
observerGAD7.startWatching();
FileObserver observerPHQ9 = new FileObserver(String.valueOf(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS + "/PHQ9_Client_Responses.db"))) {
@Override
public void onEvent(int event, String path) {
if ((FileObserver.MODIFY & event)!=0) {
System.out.println("PHQ9 file event");
//TODO EMAIL PHQ9 DATABASE AUTOMATICALLY
}
// Looper.myLooper().quit();
}
};
observerPHQ9.startWatching();
Looper.loop();
}
});
}
它返回 2 份报告来记录,而不仅仅是一份。这意味着一旦实施,将发送 2 封自动电子邮件,这并不理想。
谁能帮助我的语法?