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" }