From 96d4b11ff04335acd985cb3312b290b1d4e36055 Mon Sep 17 00:00:00 2001 From: Nicholas Ventimiglia Date: Wed, 25 Feb 2026 13:02:14 -0800 Subject: [PATCH] Updated preloading code snippets. PiperOrigin-RevId: 875299734 --- .../com/example/snippets/InterstitialAdSnippets.java | 12 +++++++++++- .../com/example/snippets/InterstitialAdSnippets.kt | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/java/NextGenExample/app/src/main/java/com/example/snippets/InterstitialAdSnippets.java b/java/NextGenExample/app/src/main/java/com/example/snippets/InterstitialAdSnippets.java index 8f3de7b..3893cdd 100644 --- a/java/NextGenExample/app/src/main/java/com/example/snippets/InterstitialAdSnippets.java +++ b/java/NextGenExample/app/src/main/java/com/example/snippets/InterstitialAdSnippets.java @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -128,5 +128,15 @@ public void onAdPaid(AdValue value) { private boolean isAdAvailable(String adUnitId) { return InterstitialAdPreloader.isAdAvailable(adUnitId); } + // [END isAdAvailable] + + // [START stop_preload] + private void stopPreloading(String adUnitId) { + // Stops the preloading and destroys preloaded ads. + InterstitialAdPreloader.destroy(adUnitId); + // Stops the preloading and destroys all ads. + InterstitialAdPreloader.destroyAll(); + } + // [END stop_preload] } diff --git a/kotlin/NextGenExample/app/src/main/java/com/example/snippets/InterstitialAdSnippets.kt b/kotlin/NextGenExample/app/src/main/java/com/example/snippets/InterstitialAdSnippets.kt index aa98959..6642668 100644 --- a/kotlin/NextGenExample/app/src/main/java/com/example/snippets/InterstitialAdSnippets.kt +++ b/kotlin/NextGenExample/app/src/main/java/com/example/snippets/InterstitialAdSnippets.kt @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -116,6 +116,16 @@ private class InterstitialAdSnippets { // [END isAdAvailable] + // [START stop_preload] + private fun stopPreloading(adUnitId: String) { + // Stops the preloading and destroys preloaded ads. + InterstitialAdPreloader.destroy(adUnitId) + // Stops the preloading and destroys all ads. + InterstitialAdPreloader.destroyAll() + } + + // [END stop_preload] + private companion object { const val TAG = "InterstitialAdSnippets" }