这是我的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封自动电子邮件,这是不理想的。
任何人都可以帮我解决语法问题吗?
答案 0 :(得分:-1)