A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/admob/android/global-settings below:

Global Settings | Android | Google for Developers

Global Settings

Stay organized with collections Save and categorize content based on your preferences.

The MobileAds class provides global settings for the Google Mobile Ads SDK.

Video ad volume control

If your app has its own volume controls (such as custom music or sound effect volumes), disclosing app volume to the Google Mobile Ads SDK allows video ads to respect app volume settings. This ensures users receive video ads with the expected audio volume.

The device volume, controlled through volume buttons or OS-level volume slider, determines the volume for device audio output. However, apps can independently adjust volume levels relative to the device volume to tailor the audio experience. For app open, banner, interstitial, rewarded, and rewarded interstitial ad formats, you can report the relative app volume to the SDK through the static setAppVolume() method. Valid ad volume values range from 0.0 (silent) to 1.0 (current device volume). Here's an example of how to report the relative app volume to the SDK:

Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)

  val backgroundScope = CoroutineScope(Dispatchers.IO)
  backgroundScope.launch {
    // Initialize the Google Mobile Ads SDK on a background thread.
    MobileAds.initialize(this@MainActivity) {}
    
    // Set app volume to be half of current device volume.
    MobileAds.setAppVolume(0.5f)
  }
}
Java
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  new Thread(
          () -> {
            // Initialize the Google Mobile Ads SDK on a background thread.
            MobileAds.initialize(this, initializationStatus -> {});
            
            // Set app volume to be half of current device volume.
            MobileAds.setAppVolume(0.5f);
          })
      .start();
}

To inform the SDK that the app volume has muted, use the setAppMuted() method:

Kotlin
MobileAds.setAppMuted(true)
Java
MobileAds.setAppMuted(true);

By default, the app volume is set to 1 (the current device volume), and the app is not muted.

Note: Video ads that are ineligible to be shown with muted audio are not returned for ad requests made when the app volume is reported as muted or set to a value of 0. This may restrict a subset of the broader video ads pool from serving. Native ads

See VideoOptions for instructions on how to control the mute settings. Custom volume control is not supported for native ads.

Consent for cookies

If your app has special requirements, you can set the optional SharedPreferences gad_has_consent_for_cookies. The SDK will enable limited ads (LTD) when the gad_has_consent_for_cookies preference is set to zero.

Kotlin
val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context)
// Set the value to 0 to enable limited ads.
sharedPrefs.edit().putInt("gad_has_consent_for_cookies", 0).apply()
Java
Context activity = getActivity();
SharedPreferences sharedPreferences =
  PreferenceManager.getDefaultSharedPreferences(activity);
// Set the value to 0 to enable limited ads.
sharedPreferences.edit().putInt("gad_has_consent_for_cookies", 0).apply();

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-05-10 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-05-10 UTC."],[[["The `MobileAds` class provides global settings for the Google Mobile Ads SDK, including video ad volume and consent for cookies."],["You can control video ad volume by setting the app volume relative to the device volume using `MobileAds.setAppVolume()` and muting with `MobileAds.setAppMuted()`."],["If your app has special requirements for cookies, you can enable limited ads by setting the `gad_has_consent_for_cookies` SharedPreference to 0."],["Native ads have separate video options and do not support custom volume control."]]],["The `MobileAds` class manages the Google Mobile Ads SDK settings. Apps can adjust video ad volume by using `setAppVolume()`, with values from 0.0 (silent) to 1.0 (device volume), ensuring video ads respect app volume. `setAppMuted()` mutes the app volume. For limited ads (LTD), setting the `gad_has_consent_for_cookies` preference to 0 enables them. The SDK default volume is 1, and the app is not muted initially. Native ads have distinct volume controls, via `VideoOptions`.\n"]]


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