MobileAds क्लास, Google Mobile Ads SDK (Legacy) के लिए ग्लोबल सेटिंग उपलब्ध कराती है.
वीडियो विज्ञापन की आवाज़ को कंट्रोल करने की सुविधा
अगर आपके ऐप्लिकेशन में अपनी वॉल्यूम कंट्रोल (जैसे कि कस्टम म्यूज़िक या साउंड इफ़ेक्ट वॉल्यूम) है, तो Google Mobile Ads SDK (Legacy) को ऐप्लिकेशन के वॉल्यूम के बारे में बताने से, वीडियो विज्ञापनों में वॉल्यूम के लिए, ऐप्लिकेशन की वॉल्यूम सेटिंग की मदद से ऐसा करने की अनुमति मिलती है. इससे यह पक्का होता है कि उपयोगकर्ताओं को वीडियो विज्ञापनों की आवाज़, उम्मीद के मुताबिक सुनाई दे.
डिवाइस के ऑडियो आउटपुट की आवाज़, डिवाइस की आवाज़ से तय होती है. इसे आवाज़ कम या ज़्यादा करने वाले बटन या ओएस-लेवल के वॉल्यूम स्लाइडर से कंट्रोल किया जाता है. हालांकि, ऐप्लिकेशन अपने हिसाब से डिवाइस के वॉल्यूम लेवल को अडजस्ट कर सकते हैं, ताकि ऑडियो का बेहतर अनुभव मिल सके. ऐप्लिकेशन खोलने पर दिखने वाले विज्ञापन, बैनर, इंटरस्टीशियल, इनाम वाले विज्ञापन, और इनाम वाले इंटरस्टीशियल विज्ञापन फ़ॉर्मैट के लिए, स्टैटिक setAppVolume() तरीके का इस्तेमाल करके, SDK टूल को ऐप्लिकेशन के वॉल्यूम की जानकारी दी जा सकती है. विज्ञापन की आवाज़ की मान्य वैल्यू, 0.0 (म्यूट) से लेकर 1.0 (डिवाइस की मौजूदा आवाज़) तक होती हैं. SDK टूल को ऐप्लिकेशन के वॉल्यूम की जानकारी देने का उदाहरण यहां दिया गया है:
Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val backgroundScope = CoroutineScope(Dispatchers.IO)
backgroundScope.launch {
// Initialize Google Mobile Ads SDK (Legacy) 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 Google Mobile Ads SDK (Legacy) on a background thread.
MobileAds.initialize(this, initializationStatus -> {});
// Set app volume to be half of current device volume.
MobileAds.setAppVolume(0.5f);
})
.start();
}
setAppMuted() तरीके का इस्तेमाल करके, SDK टूल को बताएं कि ऐप्लिकेशन की आवाज़ म्यूट कर दी गई है:
Kotlin
MobileAds.setAppMuted(true)
Java
MobileAds.setAppMuted(true);
डिफ़ॉल्ट रूप से, ऐप्लिकेशन का वॉल्यूम 1 (डिवाइस का मौजूदा वॉल्यूम) पर सेट होता है और ऐप्लिकेशन म्यूट नहीं होता.
नेटिव विज्ञापन
म्यूट करने की सेटिंग को कंट्रोल करने का तरीका जानने के लिए,
VideoOptions
देखें. नेटिव विज्ञापनों के लिए, कस्टम वॉल्यूम कंट्रोल की सुविधा उपलब्ध नहीं है.
कुकी के लिए सहमति
अगर आपके ऐप्लिकेशन के लिए खास ज़रूरी शर्तें हैं, तो आपके पास वैकल्पिक SharedPreferences gad_has_consent_for_cookies सेट करने का विकल्प है. gad_has_consent_for_cookies की प्राथमिकता को शून्य पर सेट करने पर, एसडीके विज्ञापनों को सीमित तौर पर दिखाए जाने की सुविधा (एलटीडी) को चालू कर देगा.
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();