24

I hope someone can give information about this. I display interstitial ads with Admob. Some of them have music or sounds and my users get terrible annoyed because of this. So, does anyone know if there is a way to block ads with music or sound? Is there anyway to decline access to the loud speaker for the ads? Thanks

Ton
  • 9,235
  • 15
  • 59
  • 103
  • 3
    By the way, I asked Admob and they said there is nothing to do. If the ad has audio then there is no way to filter that and there is no way to block those kind of ads. Really annoying. – Ton Jun 09 '14 at 16:15

3 Answers3

12

I had the same issue. I was shocked to hear some audio in background too. This is what I did. Mute the sound before showing the ad. Unmute the sound onAdClosed() of AdListener. You can set the adListener on the interstitial ad while loading the ad.

private InterstitialAd interstitialAd;
private void showTheAd(){
    _muteSound();
    interstitialAd.show();
}


private void loadAd(){
    interstitialAd = new InterstitialAd(context);
    interstitialAd.setAdUnitId("ca-app-pub-XXXXXXx/XXXXXXXX");
    AdRequest adRequest = new AdRequest.Builder().addTestDevice(
            AdRequest.DEVICE_ID_EMULATOR).build();
    interstitialAd.loadAd(adRequest);
    interstitialAd.setAdListener(new AdListener() {
            public void onAdClosed(){
                _unmuteSound();
            }
        });
}

private void _unmuteSound(){
    AudioManager aManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
                aManager.setStreamMute(AudioManager.STREAM_MUSIC, false);
}
private void _muteSound(){
    AudioManager aManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
                aManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
}
Angel Koh
  • 12,479
  • 7
  • 64
  • 91
Thupten
  • 2,158
  • 1
  • 24
  • 31
  • Thank you @Thupten, but i think you have to change the boolean value of the _unmuteSound function to false and the _muteSound boolean value to true?! – Calimero Mar 08 '16 at 09:00
  • 1
    Now there is an API available to mute the ads, but it doesn't work properly, specially for the meadiation ads: MobileAds.setAppMuted(true) – thiagolr Sep 17 '16 at 13:40
  • 2
    Will this solution mute also all the other sounds? For example, if the user listens to music it will also mute it ? – Piotr Sagalara Apr 19 '17 at 12:15
8

to mute an ad, just call MobileAds.setAppmuted(true)

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);

    // Set app volume to be half of current device volume.
    MobileAds.setAppVolume(0.5f); // or setAppMuted(true); to mute 
    ...
}

from their forum page: https://groups.google.com/forum/#!topic/google-admob-ads-sdk/X7hQeehlJBI

The Google Mobile Ads SDK for Android has methods to set the current volume for incoming ads, based on the device's current volume level.

setAppVolume(float) - available in the Android AdMob SDK version 8.4 and up. setAppMuted(boolean) - available in the Android AdMob SDK version 9.0 and up.

for further readings, refer to https://developers.google.com/admob/android/global-settings and https://developers.google.com/android/reference/com/google/android/gms/ads/MobileAds

Angel Koh
  • 12,479
  • 7
  • 64
  • 91
  • 7
    Unfortunately that does not work reliably. From an email I received from the support team: "setAppMuted method does not guarantee that the received video creative would honor the setting. Some creative can chose to ignore this". That is true even without a mediation flow. – devconsole Jan 08 '18 at 19:59
  • 8
    In our experience, this proposal with "MobileAds.setAppVolume(0.0f); " works fine. – Fisher May 12 '18 at 20:23
  • Notice that by muting MobileAds, the ads revenue can be affected, since you are restricting the ads inventory. "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." https://developers.google.com/admob/android/global-settings – Ayer Ribeiro de Souza Netto Feb 05 '21 at 15:30
4

Well you can log-on to your AdMob account and go to your app and then choose to edit your interstitial ad-unit link in the table that displays the ad-units for this app.

In there, you'll see 3 Ad types as check-box options - Text, Image and Video. Uncheck the Video option and save your settings.

You've now solved successfully the problem of showing loud audio/video ads that nag your users. Cheers!

karthiks
  • 7,049
  • 7
  • 47
  • 62