Wenn Sie sich mit anderen Nutzern über unsere Produkte austauschen und Feedback geben möchten, treten Sie dem offiziellen Ad Manager-Discord-Kanal auf dem Server der Google Advertising and Measurement Community bei.
Die Klasse MobileAds bietet globale Einstellungen für das Google Mobile Ads SDK.
Lautstärkeregelung für Videoanzeigen
Wenn in Ihrer App die Lautstärke separat eingestellt werden kann, z. B. für Musik oder Toneffekte, können Sie festlegen, dass Videoanzeigen an die jeweils gewählte Lautstärke angepasst werden. So werden Nutzern Videoanzeigen in der erwarteten Lautstärke präsentiert.
Die Lautstärke des Geräts, die über die Lautstärketasten oder den Lautstärkeregler auf Betriebssystemebene gesteuert wird, bestimmt die Lautstärke für die Audioausgabe des Geräts. Apps können die Lautstärke jedoch unabhängig von der Gerätelautstärke anpassen, um das Audioerlebnis zu optimieren. Bei den Anzeigenformaten App-Start-Anzeigen, Banner-, Interstitial- und Anzeigen mit Prämie sowie Interstitial-Anzeigen mit Prämie können Sie das relative App-Volumen über die statische Methode setAppVolume() an das SDK melden. Gültige Werte für die Lautstärke von Anzeigen reichen von 0.0 (stumm) bis 1.0 (aktuelle Gerätelautstärke). Hier sehen Sie ein Beispiel dafür, wie Sie das relative App-Volumen an das SDK melden:
Kotlin
overridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)valbackgroundScope=CoroutineScope(Dispatchers.IO)backgroundScope.launch{// Initialize 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
@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);newThread(()->{// Initialize 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();}
Verwenden Sie die setAppMuted()-Methode, um das SDK darüber zu informieren, dass die Lautstärke der App stummgeschaltet wurde:
Kotlin
MobileAds.setAppMuted(true)
Java
MobileAds.setAppMuted(true);
Standardmäßig ist die App-Lautstärke auf 1 (die aktuelle Gerätelautstärke) eingestellt und die App ist nicht stummgeschaltet.
Native Anzeigen
Eine Anleitung zum Steuern der Stummschaltungseinstellungen finden Sie unter VideoOptions. Die benutzerdefinierte Lautstärkeregelung wird für native Anzeigen nicht unterstützt.
Einwilligung für Cookies
Wenn Ihre App spezielle Anforderungen hat, können Sie die optionale SharedPreferences-gad_has_consent_for_cookies festlegen. Das SDK aktiviert eingeschränkte Anzeigen, wenn die Einstellung gad_has_consent_for_cookies auf null gesetzt ist.
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();
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-05 (UTC)."],[[["\u003cp\u003eThe \u003ccode\u003eMobileAds\u003c/code\u003e class provides global settings for the Google Mobile Ads SDK, including video ad volume and consent for cookies.\u003c/p\u003e\n"],["\u003cp\u003eYou can control video ad volume by setting the app volume relative to the device volume using \u003ccode\u003eMobileAds.setAppVolume()\u003c/code\u003e and muting with \u003ccode\u003eMobileAds.setAppMuted()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eWhen app volume is reported as muted or 0, video ads ineligible to be shown muted may not be returned, potentially limiting ad serving.\u003c/p\u003e\n"],["\u003cp\u003eFor native ads, video mute settings are controlled through \u003ccode\u003eVideoOptions\u003c/code\u003e, and custom volume control is not supported.\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 SharedPreferences value to 0.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/ad-manager/mobile-ads-sdk/android/global-settings \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/global-settings \"View this page for the iOS platform docs.\") [Unity](/ad-manager/mobile-ads-sdk/unity/global-settings \"View this page for the Unity platform docs.\")\n\n\u003cbr /\u003e\n\nThe `MobileAds` class provides global settings for Google 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 Google 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 `setAppVolume()` 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 Google Mobile Ads SDK on a background thread.\n MobileAds.initialize(this@MainActivity) {}\n \n // Set app volume to be half of current device volume.\n MobileAds.setAppVolume(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 Google Mobile Ads SDK on a background thread.\n MobileAds.initialize(this, initializationStatus -\u003e {});\n \n // Set app volume to be half of current device volume.\n MobileAds.setAppVolume(0.5f);\n })\n .start();\n }\n\nTo inform the SDK that the app volume has muted, use the `setAppMuted()`\nmethod: \n\nKotlin \n\n MobileAds.setAppMuted(true)\n\nJava \n\n MobileAds.setAppMuted(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\nNative ads\n\nSee\n[`VideoOptions`](/ad-manager/mobile-ads-sdk/android/native/video-ads#videooptions)\nfor instructions on how to control the mute settings. Custom volume control is\nnot supported for native ads.\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/admanager/answer/9882911)\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();"]]