From 516708a1ba400617390f808f7b8e65a0e345cb9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20G=C3=B6cer?= Date: Fri, 30 Aug 2024 20:47:35 +0200 Subject: [PATCH] Initialize the Google Mobile Ads SDK on a background thread --- .../plugins/googlemobileads/FlutterMobileAdsWrapper.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterMobileAdsWrapper.java b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterMobileAdsWrapper.java index d8d9d65c7..9121c53ee 100644 --- a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterMobileAdsWrapper.java +++ b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterMobileAdsWrapper.java @@ -36,7 +36,12 @@ public FlutterMobileAdsWrapper() {} /** Initializes the sdk. */ public void initialize( @NonNull Context context, @NonNull OnInitializationCompleteListener listener) { - MobileAds.initialize(context, listener); + new Thread( + () -> { + // Initialize the Google Mobile Ads SDK on a background thread. + MobileAds.initialize(context, listener); + }) + .start(); } /** Wrapper for setAppMuted. */