Admove add
=================================START============================================
MobileAds initialize
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});
loadfullscreenads();
AdRequest madRequest = new AdRequest.Builder().build();
mAdView.loadAd(madRequest);
==================================END===========================================
===================================START========================================
private void loadfullscreenads(){
AdRequest adRequest = new AdRequest.Builder().build();
InterstitialAd.load(this,"ca-app-pub-3940256099942544/1033173712", adRequest,
new InterstitialAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
// The mInterstitialAd reference will be null until
// an ad is loaded.
mInterstitialAd = interstitialAd;
mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){
@Override
public void onAdClicked() {
// Called when a click is recorded for an ad.
}
@Override
public void onAdDismissedFullScreenContent() {
// Called when ad is dismissed.
// Set the ad reference to null so you don't show the ad a second time.
loadfullscreenads();
}
@Override
public void onAdFailedToShowFullScreenContent(AdError adError) {
// Called when ad fails to show.
mInterstitialAd = null;
}
@Override
public void onAdImpression() {
// Called when an impression is recorded for an ad.
}
@Override
public void onAdShowedFullScreenContent() {
// Called when ad is shown.
}
});
}
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
// Handle the error
mInterstitialAd = null;
}
});
}
==================================END===========================================
=====================================AD SHOW START==============================
if (mInterstitialAd != null) {
startActivity(new Intent(MainActivity.this,Pag_10.class));
mInterstitialAd.show(MainActivity.this);
}
==================================END===========================================
No comments:
Post a Comment