Skip to content

Commit 96d4b11

Browse files
Nicholas Ventimigliacopybara-github
authored andcommitted
Updated preloading code snippets.
PiperOrigin-RevId: 875299734
1 parent 81bb5d0 commit 96d4b11

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

java/NextGenExample/app/src/main/java/com/example/snippets/InterstitialAdSnippets.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 Google LLC
1+
// Copyright 2026 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -128,5 +128,15 @@ public void onAdPaid(AdValue value) {
128128
private boolean isAdAvailable(String adUnitId) {
129129
return InterstitialAdPreloader.isAdAvailable(adUnitId);
130130
}
131+
131132
// [END isAdAvailable]
133+
134+
// [START stop_preload]
135+
private void stopPreloading(String adUnitId) {
136+
// Stops the preloading and destroys preloaded ads.
137+
InterstitialAdPreloader.destroy(adUnitId);
138+
// Stops the preloading and destroys all ads.
139+
InterstitialAdPreloader.destroyAll();
140+
}
141+
// [END stop_preload]
132142
}

kotlin/NextGenExample/app/src/main/java/com/example/snippets/InterstitialAdSnippets.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 Google LLC
1+
// Copyright 2026 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -116,6 +116,16 @@ private class InterstitialAdSnippets {
116116

117117
// [END isAdAvailable]
118118

119+
// [START stop_preload]
120+
private fun stopPreloading(adUnitId: String) {
121+
// Stops the preloading and destroys preloaded ads.
122+
InterstitialAdPreloader.destroy(adUnitId)
123+
// Stops the preloading and destroys all ads.
124+
InterstitialAdPreloader.destroyAll()
125+
}
126+
127+
// [END stop_preload]
128+
119129
private companion object {
120130
const val TAG = "InterstitialAdSnippets"
121131
}

0 commit comments

Comments
 (0)