Prevent the watcher's finalizer from being called before we're done with it.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4408 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-08-20 11:25:49 +00:00
parent 20557e8ce4
commit fef88e2032

View File

@ -1,5 +1,7 @@
package com.unprompted.tildefriends; package com.unprompted.tildefriends;
import android.os.StrictMode;
import android.os.strictmode.Violation;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -39,6 +41,7 @@ public class MainActivity extends Activity {
WebView web_view; WebView web_view;
String base_url; String base_url;
Process process; Process process;
WatchService watcher;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -89,7 +92,7 @@ public class MainActivity extends Activity {
public void run() { public void run() {
try { try {
Log.w("tildefriends", "Watching for changes in: " + getFilesDir().toString()); Log.w("tildefriends", "Watching for changes in: " + getFilesDir().toString());
WatchService watcher = FileSystems.getDefault().newWatchService(); watcher = FileSystems.getDefault().newWatchService();
Paths.get(getFilesDir().toString()).register( Paths.get(getFilesDir().toString()).register(
watcher, watcher,
StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_CREATE,
@ -104,6 +107,7 @@ public class MainActivity extends Activity {
web_view.loadUrl(base_url); web_view.loadUrl(base_url);
}); });
watcher.close(); watcher.close();
watcher = null;
break; break;
} }
} }