我有一个服务:
public class FileObserverService extends Service {
private FileObserverForNewFirFiles fObs;
@Override
public void onCreate() {
Log.i("FILE_OBSERVER_SERVICE: ", "INSIDE ONCREATE()");
File f = new File("/mnt/sdcard/Bluetooth");
createFileObserver(f);
}
public void createFileObserver(File f) {
if(!f.isDirectory()) {
Log.i("FILEOBSERVER: ", "FILE NOT A DIRECTORY!");
}
else {
fObs = new FileObserverForNewFirFiles(f.getAbsolutePath());
}
}
@Override
public void onStart(Intent i, int startid) {
fObs.startWatching();
Toast.makeText(this.getApplicationContext(), "start monitoring file modification", Toast.LENGTH_SHORT).show();
}
@Override
public void onDestroy() {
fObs.stopWatching();
Toast.makeText(this.getApplicationContext(), "stop monitoring file modification", Toast.LENGTH_SHORT).show();
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
}
在我的主要活动中,我这样称呼这个类:
startService(new Intent(ThisClass.this, FileObserverService.class));
我认为该onCreate
方法会向 打印出一些东西LogCat
,指的是该方法的第一行。但它似乎没有这样做。任何打击?