diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ServiceWorkerManager.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ServiceWorkerManager.java index ac2a654f..b9ff2958 100755 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ServiceWorkerManager.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ServiceWorkerManager.java @@ -168,13 +168,7 @@ public class ServiceWorkerManager implements MethodChannel.MethodCallHandler { } private ServiceWorkerClientCompat dummyServiceWorkerClientCompat() { - return new ServiceWorkerClientCompat() { - @Nullable - @Override - public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) { - return null; - } - }; + return DummyServiceWorkerClientCompat.INSTANCE; } public void dispose() { @@ -185,4 +179,14 @@ public class ServiceWorkerManager implements MethodChannel.MethodCallHandler { } plugin = null; } + + private static final class DummyServiceWorkerClientCompat extends ServiceWorkerClientCompat { + static final ServiceWorkerClientCompat INSTANCE = new DummyServiceWorkerClientCompat(); + + @Nullable + @Override + public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) { + return null; + } + } }