From fef88e2032dd83b14d596f4f0372a9129e64d862 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 20 Aug 2023 11:25:49 +0000 Subject: [PATCH] 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 --- src/android/com/unprompted/tildefriends/MainActivity.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/android/com/unprompted/tildefriends/MainActivity.java b/src/android/com/unprompted/tildefriends/MainActivity.java index a1f5232b..d3a240ea 100644 --- a/src/android/com/unprompted/tildefriends/MainActivity.java +++ b/src/android/com/unprompted/tildefriends/MainActivity.java @@ -1,5 +1,7 @@ package com.unprompted.tildefriends; +import android.os.StrictMode; +import android.os.strictmode.Violation; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; @@ -39,6 +41,7 @@ public class MainActivity extends Activity { WebView web_view; String base_url; Process process; + WatchService watcher; @Override protected void onCreate(Bundle savedInstanceState) { @@ -89,7 +92,7 @@ public class MainActivity extends Activity { public void run() { try { Log.w("tildefriends", "Watching for changes in: " + getFilesDir().toString()); - WatchService watcher = FileSystems.getDefault().newWatchService(); + watcher = FileSystems.getDefault().newWatchService(); Paths.get(getFilesDir().toString()).register( watcher, StandardWatchEventKinds.ENTRY_CREATE, @@ -104,6 +107,7 @@ public class MainActivity extends Activity { web_view.loadUrl(base_url); }); watcher.close(); + watcher = null; break; } }