Stay organized with collections
Save and categorize content based on your preferences.
The MobileAds class provides global settings for Next Gen 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 Next Gen 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 setUserControlledAppVolume() 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
overridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)valbackgroundScope=CoroutineScope(Dispatchers.IO)backgroundScope.launch{// Initialize Next Gen Mobile Ads SDK on a background thread.MobileAds.initialize(this@MainActivity,// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713InitializationConfig.Builder("SAMPLE_APP_ID").build()){}// Set app volume to be half of current device volume.MobileAds.setUserControlledAppVolume(0.5f)}}
Java
@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);newThread(()->{// Initialize Next Gen Mobile Ads SDK on a background thread.MobileAds.initialize(this,// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713newInitializationConfig.Builder("SAMPLE_APP_ID").build(),initializationStatus->{});// Set app volume to be half of current device volume.MobileAds.setUserControlledAppVolume(0.5f);}).start();}
To inform the SDK that the app volume has muted, use the setUserMutedApp()
method:
Kotlin
MobileAds.setUserMutedApp(true)
Java
MobileAds.setUserMutedApp(true);
By default, the app volume is set to 1 (the current device volume), and the
app is not muted.
Consent for cookies
If your app has special requirements, you can set the optional
SharedPreferencesgad_has_consent_for_cookies. The SDK will enable
limited ads (LTD)
when the gad_has_consent_for_cookies preference is set to zero.
Kotlin
valsharedPrefs=PreferenceManager.getDefaultSharedPreferences(context)// Set the value to 0 to enable limited ads.sharedPrefs.edit().putInt("gad_has_consent_for_cookies",0).apply()
Java
Contextactivity=getActivity();SharedPreferencessharedPreferences=PreferenceManager.getDefaultSharedPreferences(activity);// Set the value to 0 to enable limited ads.sharedPreferences.edit().putInt("gad_has_consent_for_cookies",0).apply();
[[["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-09-04 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eMobileAds\u003c/code\u003e class provides global settings for the Google Mobile Ads SDK, including features to control video ad volume and user consent for cookies.\u003c/p\u003e\n"],["\u003cp\u003eYou can manage video ad volume relative to the device volume using \u003ccode\u003esetUserControlledAppVolume()\u003c/code\u003e and \u003ccode\u003esetUserMutedApp()\u003c/code\u003e to enhance user experience.\u003c/p\u003e\n"],["\u003cp\u003eReporting app volume as muted (\u003ccode\u003esetUserMutedApp(true)\u003c/code\u003e) or 0 (\u003ccode\u003esetUserControlledAppVolume(0f)\u003c/code\u003e) may limit the range of video ads eligible to serve.\u003c/p\u003e\n"],["\u003cp\u003eTo enable limited ads due to specific consent requirements, set the \u003ccode\u003egad_has_consent_for_cookies\u003c/code\u003e SharedPreference to 0.\u003c/p\u003e\n"]]],[],null,["The `MobileAds` class provides global settings for Next Gen Mobile Ads SDK.\n\nVideo ad volume control\n\nIf your app has its own volume controls (such as custom music or sound effect\nvolumes), disclosing app volume to Next Gen Mobile Ads SDK allows video ads to\nrespect app volume settings. This ensures users receive video ads with the\nexpected audio volume.\n\nThe device volume, controlled through volume buttons or OS-level volume slider,\ndetermines the volume for device audio output. However, apps can independently\nadjust volume levels relative to the device volume to tailor the audio\nexperience. For app open, banner, interstitial, rewarded, and rewarded\ninterstitial ad formats, you can report the relative app volume to the SDK\nthrough the static `setUserControlledAppVolume()` method. Valid ad volume values range from\n`0.0` (silent) to `1.0` (current device volume). Here's an example of how to\nreport the relative app volume to the SDK: \n\nKotlin \n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n\n val backgroundScope = CoroutineScope(Dispatchers.IO)\n backgroundScope.launch {\n // Initialize Next Gen Mobile Ads SDK on a background thread.\n MobileAds.initialize(\n this@MainActivity,\n // Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713\n InitializationConfig.Builder(\"\u003cvar class=\"readonly\" translate=\"no\"\u003eSAMPLE_APP_ID\u003c/var\u003e\").build()\n ) {}\n \n // Set app volume to be half of current device volume.\n MobileAds.setUserControlledAppVolume(0.5f)\n }\n }\n\nJava \n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n new Thread(\n () -\u003e {\n // Initialize Next Gen Mobile Ads SDK on a background thread.\n MobileAds.initialize(\n this,\n // Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713\n new InitializationConfig.Builder(\"\u003cvar class=\"readonly\" translate=\"no\"\u003eSAMPLE_APP_ID\u003c/var\u003e\")\n .build(),\n initializationStatus -\u003e {\n });\n \n // Set app volume to be half of current device volume.\n MobileAds.setUserControlledAppVolume(0.5f);\n })\n .start();\n }\n\nTo inform the SDK that the app volume has muted, use the `setUserMutedApp()`\nmethod: \n\nKotlin \n\n MobileAds.setUserMutedApp(true)\n\nJava \n\n MobileAds.setUserMutedApp(true);\n\nBy default, the app volume is set to `1` (the current device volume), and the\napp is not muted.\n| **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.\n\nConsent for cookies\n\nIf your app has special requirements, you can set the optional\n[`SharedPreferences`](//developer.android.com/reference/android/content/SharedPreferences)\n`gad_has_consent_for_cookies`. The SDK will enable\n\n[limited ads (LTD)](//support.google.com/admob/answer/10105530)\n\nwhen the `gad_has_consent_for_cookies` preference is set to zero. \n\nKotlin \n\n val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context)\n // Set the value to 0 to enable limited ads.\n sharedPrefs.edit().putInt(\"gad_has_consent_for_cookies\", 0).apply()\n\nJava \n\n Context activity = getActivity();\n SharedPreferences sharedPreferences =\n PreferenceManager.getDefaultSharedPreferences(activity);\n // Set the value to 0 to enable limited ads.\n sharedPreferences.edit().putInt(\"gad_has_consent_for_cookies\", 0).apply();"]]