I see a lot of android app show AdMob interstitial ads without audio that users can unmute than by clicking a speaker button in the ad.
Are all those interstitials muted by default?
Or Do I have to use this method for that AdMob Global Settings
MobileAds.initialize(this, new OnInitializationCompleteListener() {
#Override
public void onInitializationComplete(InitializationStatus initializationStatus) {}
});
//To inform the SDK that the app volume has been muted, use the setAppMuted() method:
MobileAds.setAppMuted(true);
MobileAds.initialize(this, new OnInitializationCompleteListener() {
#Override
public void onInitializationComplete(InitializationStatus initializationStatus) {}
});
// 0.5 is the least you can reduce
MobileAds.setAppVolume(0.5);
Set it up
Related
About a year ago i finished a super simple game in android studio and published it. Now i wanted to make a small update and show ads on more proper place. But ads won't work at all - code is the same as it was, but ads just won't load.
My account is not disabled since if I download my game from playstore ads still work.
I use different version of android studio, so the project upgraded itself, but I don't know if it changed graddle or manifest or something so this could happen.
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-xxxxxxxxxxxxxx/xxxxxxxx");
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mInterstitialAd.setAdListener(new AdListener() {
#Override
public void onAdLoaded () {
if(enableAd) {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
}
}
});
Use onAdClosed() in your AdListener to reload your ad each time is has been displayed, and create your initial Ad as part of the mainActivity.create().
Use mInterstitialAd.show() anywhere in your app when you want to show the ad. After it is shown, it closes and will reload the next ad.
What this does is buffers your Ad. Whenever you show the interstitial ad, it shows the one that is already loaded, then reloads a new one after you've shown the ad. Makes for a quicker ad.show().
mInterstatialAd = new InterstitialAd(getBaseContext());
mInterstatialAd.setAdUnitId(getResources()
.getString(R.string.AdmobTestInterstitial));
mInterstitialAd.setAdListener(new AdListener() {
#Override
public void onAdClosed () {
mInterstatialAd.loadAd(myAdRequest);
}
});
public void showMyInterstitialAd(){
if(mInterstitialAd!=null &&
mInstitialAd.isLoaded()) mInterstitialAd.show();
}
good luck.
I've added the Admob ad to our Android app. I'm getting Advertising from Android Studio. I receive ads when I manually install the APK file to the phone. However, I can't get ads when I upload the app to Google Play and download it from Google Play. I get error code 3 (ERROR_CODE_NO_FILL). I couldn't find the solution. PLEASE HELP !
android studio avd run img:
img1
when I manually install the APK file to the phone:
img2
When I download it from Google Play:
img3
#Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.AppTheme_NoActionBar);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
loadAdmobBanner();
AdmobBannerListener();
}
private void loadAdmobBanner() {
MobileAds.initialize(this, getString(R.string.admob_app_id));
mAdView_Banner = findViewById(R.id.adView_Banner_Main);
AdRequest adRequest = new AdRequest.Builder()
.build();
mAdView_Banner.loadAd(adRequest);
}
private void AdmobBannerListener(){
mAdView_Banner.setAdListener(new AdListener(){
#Override
public void onAdFailedToLoad(int i) {
super.onAdFailedToLoad(i);
Toast.makeText(MainActivity.this, String.valueOf(i), Toast.LENGTH_SHORT).show();
}
#Override
public void onAdClosed() {
super.onAdClosed();
}
#Override
public void onAdLeftApplication() {
super.onAdLeftApplication();
}
#Override
public void onAdOpened() {
super.onAdOpened();
}
#Override
public void onAdLoaded() {
super.onAdLoaded();
}
#Override
public void onAdClicked() {
super.onAdClicked();
}
#Override
public void onAdImpression() {
super.onAdImpression();
}
});
}
Please go to admobs account. > Go to app > ad units> check if add units are active and are associated with advertiser.
Usually adMob will take time to do this job.
I have received admob policy violation email
LAYOUT ENCOURAGES ACCIDENTAL CLICKS - INTERSTITIAL ADS:
Interstitial ads that load unexpectedly while a user is viewing the app’s content.
Below is my implementation. Please let me know if there is anything wrong with this
private void initShareInterstitial() {
shareInterstitialAd = new InterstitialAd(this);
shareInterstitialAd.setAdUnitId(getString(R.string.share_int));
shareInterstitialAd.loadAd(new AdRequest.Builder().build());
shareInterstitialAd.setAdListener(new AdListener() {
#Override
public void onAdClosed() {
// Load the next interstitial.
shareInterstitialAd.loadAd(new AdRequest.Builder().build());
new ShareTask().execute();
}
#Override
public void onAdFailedToLoad(int i) {
shareInterstitialAd.loadAd(new AdRequest.Builder().build());
}
#Override
public void onAdLeftApplication() {
shareInterstitialAd.loadAd(new AdRequest.Builder().build());
}
});
}
in OnCreate Method I am using this code on share button onclick action
if (shareInterstitialAd.isLoaded()
&& random.nextBoolean()
&& random.nextBoolean()) {
shareInterstitialAd.show();
} else {
new ShareTask().execute();
}
Your post codes are not enough to describe the flow to show interstitial ads.
From the limited codes, it is possible that you show App's contents first, then interstitial to overlap the contents. That violates Admob policy. The interstitial has to be shown before the content displayed.
You can refer to their disallowed examples.
Disallowed interstitial implementations
In my application i need to show on overlay view only on home screen. At this moment my overlay view is shown not only on home screen but also on top of any launched activity. Are there any ways of detecting that user is leaving or opening home screen?
My application is developed in the next way:
I have a Service where i am creating a view and adding it to WindowManager with this flag WindowManager.LayoutParams.TYPE_SYSTEM_ALERT. And i am also have this permission in AndroidManifest
#Override
protected void onDestroy() {
super.onDestroy();
}
#Override
protected void onResume() {
super.onResume();
}
#Override
protected void onStart() {
super.onStart();
}
http://developer.android.com/reference/android/app/Activity.html
I just made game like ironpants, I'm trying to put interstitial ads when the game over.
but the interstitial ads always show in the middle of the game. I think it'll be annoying for users. and I'm afraid if Google will banned my admob account.
The interstitial ads only show after 5x game over.
I only have onescreen MainGameView.java
here's the code to show admob interstitial ads when the game was over
the methods to initialize the interstitial ads
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initialiseAccelerometer();
// Create the interstitial
interstitial = new InterstitialAd(this, getResources().getString(R.string.InterstitialAd_unit_id));
}
public void openAd() {
runOnUiThread(new Runnable() {
public void run() {
// Create ad request
AdRequest adRequest = new AdRequest();
// Begin loading your interstitial
interstitial.loadAd(adRequest);
// Set Ad Listener to use the callbacks below
interstitial.setAdListener(new AdListener() {
#Override
public void onReceiveAd(Ad arg0) {
if (interstitial.isReady()) {
interstitial.show();
}
}
#Override
public void onPresentScreen(Ad arg0) {
}
#Override
public void onLeaveApplication(Ad arg0) {
}
#Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
}
#Override
public void onDismissScreen(Ad arg0) {
}
});
}
});
}
and I call openAd() method when the game was over
public synchronized void GameOver() {
if (adounter >= this.getResources().getInteger(R.integer.add_shows_every_X_gameovers)) {
openAd();
adounter = 0;
}
adounter++;
}
thank you very much and sorry for my bad English.
Your problem is that you are showing the interstitial d as soon as it is received (ie in AdListener#onReceiveAd). Don't do this. It provides a poor user experience and will ensure you get low ratings.
Instead show your add at a natural break in your app.
Instead show your add at a natural break in your app.
Exactly, to be more precise it would be good user experience if you do the following:
- request for the ad in onCreate
- in GameOver call:
if (interstitial.isReady()) {
interstitial.show();
}