Skip to content

Instantly share code, notes, and snippets.

@saymanrifat
Last active May 2, 2022 05:59
Show Gist options
  • Save saymanrifat/93ddf5318b488f1cdaf199f08bbdb68b to your computer and use it in GitHub Desktop.
Save saymanrifat/93ddf5318b488f1cdaf199f08bbdb68b to your computer and use it in GitHub Desktop.
Best Way to set interstitial ads
Button button = findViewById(R.id.showAds);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mInterstitialAd != null) {
mInterstitialAd.show(MainActivity.this);
mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){
//Ads Dismissed here
@Override
public void onAdDismissedFullScreenContent() {
Intent intent = new Intent(FirstActivity.this,SecondActivity.class);
startActivity(intent);
//Load your Ads Again
}
});
} else {
Intent intent = new Intent(FirstActivity.this,SecondActivity.class);
startActivity(intent);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment