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
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);
}
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
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!
Related
After the change of the version of google services ads, the addTestDevice option no longer appears, how can I see bonus videos on a physical device?
AdRequest adRequest = new AdRequest.Builder().build();
RewardedAd.load(this, "ca-app-pub-3940256099942544/5224354917",
adRequest, new RewardedAdLoadCallback() {
#Override
public void onAdFailedToLoad(#NonNull LoadAdError loadAdError) {
// Handle the error.
// Log.d(TAG, loadAdError.getMessage());
mRewardedAd = null;
}
#Override
public void onAdLoaded(#NonNull RewardedAd rewardedAd) {
mRewardedAd = rewardedAd;
//Log.d(TAG, "Ad was loaded.");
}
});
You can follow steps here
Add a test device To make changes to a test device, such as enabling
or changing ad inspector gestures, you’ll need to remove the test
device and set it up again. Sign in to your AdMob account at
https://apps.admob.com.
Click Settings in the sidebar.
Click the Test devices tab.
Click Add test device.
Select the platform of your device.
Enter a device name. Consider using a name that will help you quickly
identify your devices in your AdMob account.
Note: The device name will be visible to anyone who has access to your
AdMob account.
Enter your Advertising ID/IDFA. Learn how to find your advertising
ID/IDFA.
Select a gesture to use to activate ad inspector:
None. If you select none, you can still activate ad inspector with an
API call. Learn more.
Shake
Flick twice
Click Done.
During testing of my application, I noticed that I very frequently get ERROR_CODE_NO_FILL for Interstitial Ad. I think that the same situation with real ads might be one of the causes of low income from the application, so I want to increase the rate of showed ads. As the solution, I decided to make requests until I will get some app, so it might take from 5 to 50 requests until I will get out of onAdFailedToLoad. Is it a legitimate way to do this? Won't I get banned by AdMob with such way of getting more ads?
That's what I do in setAdListener in onCreate:
#Override
public void onAdFailedToLoad(int errorCode) {
requestNewInterstitial();
}
And requestNewInterstitial():
private void requestNewInterstitial() {
AdRequest adRequest = new AdRequest.Builder()
.build();
mInterstitialAd.loadAd(adRequest);
}
No, you won't get banned...
You can do this, but don't show the Ad as soon it is loaded, this will be a bombarding of Ads & user won't like that...
We want to integrate Reward Video Ads in our app (https://firebase.google.com/docs/admob/android/rewarded-video).
The ads work great if we don't provide the test device. However, if we do, we receive error code 0 aka ERROR_CODE_INTERNAL_ERROR, so the execution goes through onRewardedVideoAdFailedToLoad.
Is this something somebody else has encountered?
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_ad);
MobileAds.initialize(this, APP_ID);
mAd = MobileAds.getRewardedVideoAdInstance(this);
mAd.setRewardedVideoAdListener(this);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("C67A1A9F2F19699874B7718074819FF9") // Test devices don't work work with rewarded video ads.
.build();
mAd.loadAd(AD_UNIT_ID, adRequest);
}
#Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
Toast.makeText(this, "onRewardedVideoAdFailedToLoad", Toast.LENGTH_SHORT).show();
}
I revisited this in November 2017 and the test device flag DOES now work with rewarded video Ads.
You can't use test devices for rewarded video, from this forum post:
"For Reward Videos, the following are our test Ad Unit ID:
iOS - ca-app-pub-3940256099942544/1712485313
Android - ca-app-pub-3940256099942544/5224354917
Note that Reward Video Ad Unit IDs are platform specific"
When my character crosses a finish line, I play a "win" sound. I have an AudioSource object to which I simply call PlayOneShot and pass it my AudioClip as:
public void PlayWon() {
if (GameData.Data.Settings.SoundsOn) {
AudioSource audio = GetComponent<AudioSource>();
audio.Stop();
audio.PlayOneShot(WinSound);
}
}
My settings for the AudioSource are this:
and the object where this is attached to is loaded in a Loader scene which is never destroyed. I ensure this by calling:
DontDestroyOnLoad(this);
on Awake.
My sound plays fine on iOS, iPhone and iPads. But when testing on my Samsung Galaxy Tab S, the sound plays and then pauses whilst the interstitial advert is displayed and then when dismissed, the sound carries on. I am using Chartboost and Admob and use the basic invoke:
if (Chartboost.hasInterstitial(CBLocation.LevelComplete)) {
Debug.Log("Showing CB Ad");
Chartboost.showInterstitial(CBLocation.LevelComplete);
}
else if (_admobInterstitial.IsLoaded()) {
Debug.Log("Showing Admob Ad");
_admobInterstitial.Show();
}
else {
Debug.Log("Neither cached, trying CB again");
Chartboost.cacheInterstitial(CBLocation.LevelComplete);
Chartboost.showInterstitial(CBLocation.LevelComplete);
}
Any ideas why my sounds cut out on this device? I don't have another Android device to test it on but I'm assuming it's an Android related problem. The sound cuts out on both Chartboost and Admob.
Thanks
You can use a coroutine for playing the sound. When the coroutine is finished, you can show ads.
private IEnumerator PlaySoundAndShowAd()
{
//play sound
yield return new WaitForSeconds(1.0f)
//show ads or do something.
}
In my app I put Interstitial full page ad. And it is working fine on most phones but when I checked in my friends Galaxy Note 1 the Interstitial ad is repeating and reating. I don't know why it is happening in one mobile phone only.. I checked with more than three other mobile phoe including Samsung Galaxy S2, S3 etc... but in those phones there was no problem and I tested in Emulator also.. there was no problem once i closed the Ad it will not repeat. The problem is with this particular phone , if anybody knows the reason please help... Is this the problem with memory or somethiing ..
I am giving the code below.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.tabpmnth_xm);
// Create the interstitial.
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("ca-app-pub-xxxxxxxxxxxx8x/x2xxxxxxxx");
// Create ad request.
AdRequest aadRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("xxxxxxxxxxxxxxxxxxxx")
.build();
// Begin loading your interstitial.
interstitial.loadAd(aadRequest);
interstitial.setAdListener(new AdListener(){
public void onAdLoaded(){
displayInterstitial();
}
});
public void displayInterstitial() {
if (interstitial.isLoaded()) {
interstitial.show();
}
}
Sorry Jocheved for the late replay. If this problem is not happening in every phone it could possibly the problem is in that user's mobile settings. Just check whether in his/her " settings > Developer Options > Do not keep activities " selected or not. If it is selected then the app will destroy every activities as soon as the user left the current activity. So when an interstitial is displayed , the current activity will be normally in onPause. but it will be destroyed and when the user close the interstitial and come back again oncreate will run and the ad will display. To avoid this situation you can inform the user to check whether the option is selected or not.. or otherwise u may need to find some other solution and solve it through programming. thanks..
https://groups.google.com/forum/#!topic/google-admob-ads-sdk/i6zOe2Hy-xc
Check out above link where Google admob engineer has explained why this issue is arising for you. Don't need to include displayInterstitial() inside onAdLoaded(). Either you want to display your interstitial after some time, I use onCountdownTimer() myself to achieve this. For e.g. showing an Ad after 5 seconds.
new CountDownTimer(5000, 5) {
#Override
public void onTick(long millisUntilFinished) {
}
#Override
public void onFinish() {
displayInterstitial();
}
}.start();