diff --git a/CHANGELOG.md b/CHANGELOG.md index 332f02d6..7cad85cc 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ - Fixed iOS `findNext` - Fixed Android `RendererPriorityPolicy.waivedWhenNotVisible` type 'Null' is not a subtype of type 'bool' - Fixed iOS 14.0 crash when calling `callAsyncJavaScript` method +- Merged "Android fix leaking MethodChannel through anonymous class" [#1201](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1201) (thanks to [emakar](https://github.com/emakar)) ## 5.4.4+3 diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerManager.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerManager.java index c2d7ae4d..b188ab0e 100755 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerManager.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerManager.java @@ -88,13 +88,7 @@ public class ServiceWorkerManager implements Disposable { } private ServiceWorkerClientCompat dummyServiceWorkerClientCompat() { - return new ServiceWorkerClientCompat() { - @Nullable - @Override - public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) { - return null; - } - }; + return DummyServiceWorkerClientCompat.INSTANCE; } @Override @@ -109,4 +103,14 @@ public class ServiceWorkerManager implements Disposable { } 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; + } + } }