Google Mobile Ads SDK
com.google.android.gms.ads.admanager
com.google.android.gms.ads.appopen
com.google.android.gms.ads.formats
com.google.android.gms.ads.initialization
com.google.android.gms.ads.interstitial
com.google.android.gms.ads.mediation
com.google.android.gms.ads.mediation.customevent
com.google.android.gms.ads.mediation.rtb
com.google.android.gms.ads.nativead
com.google.android.gms.ads.preload
com.google.android.gms.ads.query
com.google.android.gms.ads.rewarded
com.google.android.gms.ads.rewardedinterstitial
Google User Messaging Platform SDK
Stay organized with collections Save and categorize content based on your preferences.
public class MobileAds
Class contains logic that applies to the Google Mobile Ads SDK as a whole. Right now, the only methods in it are used for initialization.
Summary Constantsstatic final String
ERROR_DOMAIN = "com.google.android.gms.ads"
Default error domain name for the Google Mobile Ads SDK.
Public methodsstatic void
disableMediationAdapterInitialization(Context context)
Call before initialize
or the first ad request to disable mediation adapter initialization.
static @Nullable InitializationStatus
getInitializationStatus()
Gets the SDK initialization status.
static @NonNull RequestConfiguration
getRequestConfiguration()
Gets the global RequestConfiguration
.
static VersionInfo
getVersion()
Gets the external version (for example, 20.6.0) of the Google Mobile Ads SDK.
static void
@RequiresPermission(value = Manifest.permission.INTERNET)
initialize(Context context)
Initializes the Google Mobile Ads SDK.
static void
initialize(Context context, OnInitializationCompleteListener listener)
Initializes the Google Mobile Ads SDK.
static void
openAdInspector(Context context, OnAdInspectorClosedListener listener)
Opens the ad inspector UI.
static void
openDebugMenu(Context context, String adUnitId)
Opens the debug menu.
static boolean
putPublisherFirstPartyIdEnabled(boolean enabled)
Controls whether the Google Mobile Ads SDK publisher first-party ID, formerly known as the same app key, is enabled.
static @Nullable CustomTabsSession
registerCustomTabsSession(
@NonNull Context context,
@NonNull CustomTabsClient client,
@NonNull String origin,
@Nullable CustomTabsCallback callback
)
Registers a CustomTabsClient
with the Google Mobile Ads SDK to improve in-app ad monetization of ads within this CustomTabsSession
.
static void
registerWebView(@NonNull WebView webview)
Registers a WebView
with the Google Mobile Ads SDK to improve in-app ad monetization of ads within this WebView
.
static void
setAppMuted(boolean muted)
Indicates whether the application's audio is muted.
static void
setAppVolume(float volume)
Sets the application's audio volume.
static void
setRequestConfiguration(
@NonNull RequestConfiguration requestConfiguration
)
Sets the global RequestConfiguration
that will be used for every AdRequest
during the app's session.
static void
startPreload(
@NonNull Context context,
@NonNull List<PreloadConfiguration> preloadConfigurations,
@NonNull PreloadCallback preloadCallback
)
Starts preloading ads for the given configurations.
Constantspublic static final String ERROR_DOMAIN = "com.google.android.gms.ads"
Default error domain name for the Google Mobile Ads SDK.
Public methods disableMediationAdapterInitializationpublic static void disableMediationAdapterInitialization(Context context)
Call before initialize
or the first ad request to disable mediation adapter initialization. This method is a noop once initialize
or the first ad request is made.
Warning: Calling this method may negatively impact your mediation performance. This method should only be called if you include mediation adapters in your app, but you don't plan to use Google mediation during this app session (for example, you are running an A/B test).
public static VersionInfo getVersion()
Gets the external version (for example, 20.6.0) of the Google Mobile Ads SDK.
initialize
doesn't need to be called prior to this function.
@RequiresPermission(value = Manifest.permission.INTERNET)
public static void initialize(Context context)
Initializes the Google Mobile Ads SDK.
Call this method as early as possible after the app launches to reduce latency on the session's first ad request.
If this method is not called, the first ad request automatically initializes the Google Mobile Ads SDK.
public static void initialize(Context context, OnInitializationCompleteListener listener)
Initializes the Google Mobile Ads SDK.
Call this method as early as possible after the app launches to reduce latency on the session's first ad request.
If this method is not called, the first ad request automatically initializes the Google Mobile Ads SDK.
putPublisherFirstPartyIdEnabledpublic static boolean putPublisherFirstPartyIdEnabled(boolean enabled)
Controls whether the Google Mobile Ads SDK publisher first-party ID, formerly known as the same app key, is enabled.
The ID is enabled by default. When disabled, the setting is persisted across app sessions and the ID is cleared.
initialize
must be called prior to this function.
boolean enabled
boolean true if the publisher first-party ID is enabled, false otherwise.
Returnsboolean
true if the decision is persisted successfully. False if it fails to be persisted.
public static void setAppMuted(boolean muted)
Indicates whether the application's audio is muted. Affects initial mute state for all ads.
Warning: Muting your application reduces video ad eligibility and may reduce your app's ad revenue. You should only utilize this API if your app provides a custom mute control to the user, and you should reflect the user's mute decision in this API.
Parametersboolean muted
true if the app is muted, false otherwise. Defaults to false.
public static void setAppVolume(float volume)
Sets the application's audio volume. Affects audio volumes of all ads relative to other audio output.
Warning: Lowering your app's audio volume reduces video ad eligibility and may reduce your app's ad revenue. You should only utilize this API if your app provides custom volume controls to the user, and you should reflect the user's volume choice in this API.
Parametersfloat volume
the volume as a float from 0 (muted) to 1.0 (full media volume). Defaults to 1.0
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-12 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-12 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3