InterstitialAd mInterstitialAd;
private InterstitialAd interstitial;
Main Activity.java (onCreate)
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
// Prepare the Interstitial Ad
interstitial = new InterstitialAd(MainActivity.this);
// Insert the Ad Unit ID
interstitial.setAdUnitId(getString(R.string.admob_interstitial_id));
interstitial.loadAd(adRequest);
// Prepare an Interstitial Ad Listener
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
// Call displayInterstitial() function
displayInterstitial();
}
});
}
public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
if (interstitial.isLoaded()) {
interstitial.show();
}
}Activity_main.xml
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3952990728602215/8548138282" />Build.gradle
compile 'com.google.firebase:firebase-ads:11.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-ads:11.0.1'
Here are the code snippets of the ads in Secret of Healthy Eyes:
InterstitialAd mInterstitialAd;
private InterstitialAd interstitial;
Main Activity.java (onCreate)
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
// Prepare the Interstitial Ad
interstitial = new InterstitialAd(MainActivity.this);
// Insert the Ad Unit ID
interstitial.setAdUnitId(getString(R.string.admob_interstitial_id));
interstitial.loadAd(adRequest);
// Prepare an Interstitial Ad Listener
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
// Call displayInterstitial() function
displayInterstitial();
}
});
}
public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
if (interstitial.isLoaded()) {
interstitial.show();
}
}
}Activity_main.xml<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id" />Build.gradlecompile 'com.google.android.gms:play-services-ads:11.0.2'
Secret of Healthy Eyes:
In some activities ads shows here :
I am here to give you other information you want :) please don't hesitate.
Best Wishes
Muhammad Shaheer Raza
Can you please more clarify the No fill error ? & how can i able to solve the No fill error issue in my apps?.
Please also tell me the method that how can i test my ads through your sample apps.