use of com.google.android.gms.ads.InterstitialAd in project quickstart-android by firebase.
the class MainActivity method onCreate.
// [END_EXCLUDE]
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
// [END load_banner_ad]
// AdMob ad unit IDs are not currently stored inside the google-services.json file.
// Developers using AdMob can store them as custom values in a string resource file or
// simply use constants. Note that the ad units used here are configured to return only test
// ads, and should not be used outside this sample.
// [START instantiate_interstitial_ad]
// Create an InterstitialAd object. This same object can be re-used whenever you want to
// show an interstitial.
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
// [END instantiate_interstitial_ad]
// [START create_interstitial_ad_listener]
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
requestNewInterstitial();
beginSecondActivity();
}
@Override
public void onAdLoaded() {
// [START_EXCLUDE]
if (mLoadInterstitialButton != null) {
mLoadInterstitialButton.setEnabled(true);
}
// [END_EXCLUDE]
}
@Override
public void onAdFailedToLoad(int i) {
// See https://goo.gl/sCZj0H for possible error codes.
Log.w(TAG, "onAdFailedToLoad:" + i);
}
});
// [END create_interstitial_ad_listener]
// [START display_interstitial_ad]
mLoadInterstitialButton = (Button) findViewById(R.id.load_interstitial_button);
mLoadInterstitialButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
beginSecondActivity();
}
}
});
// [END display_interstitial_ad]
// Disable button if an interstitial ad is not loaded yet.
mLoadInterstitialButton.setEnabled(mInterstitialAd.isLoaded());
}
use of com.google.android.gms.ads.InterstitialAd in project mopub-android-mediation by mopub.
the class GooglePlayServicesInterstitial method loadInterstitial.
@Override
protected void loadInterstitial(final Context context, final CustomEventInterstitialListener customEventInterstitialListener, final Map<String, Object> localExtras, final Map<String, String> serverExtras) {
mInterstitialListener = customEventInterstitialListener;
final String adUnitId;
if (extrasAreValid(serverExtras)) {
adUnitId = serverExtras.get(AD_UNIT_ID_KEY);
} else {
mInterstitialListener.onInterstitialFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
return;
}
mGoogleInterstitialAd = new InterstitialAd(context);
mGoogleInterstitialAd.setAdListener(new InterstitialAdListener());
mGoogleInterstitialAd.setAdUnitId(adUnitId);
final AdRequest adRequest = new AdRequest.Builder().setRequestAgent("MoPub").build();
try {
mGoogleInterstitialAd.loadAd(adRequest);
} catch (NoClassDefFoundError e) {
// This can be thrown by Play Services on Honeycomb.
mInterstitialListener.onInterstitialFailed(MoPubErrorCode.NETWORK_NO_FILL);
}
}
use of com.google.android.gms.ads.InterstitialAd in project Pitampura_Android_2018_Spring by coding-blocks-archives.
the class AdsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ads);
MobileAds.initialize(this, "ca-app-pub-2481965894320784~1015036453");
AdView mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917", new AdRequest.Builder().build());
mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
@Override
public void onRewardedVideoAdLoaded() {
// Show the ad once loaded
}
@Override
public void onRewardedVideoAdOpened() {
}
@Override
public void onRewardedVideoStarted() {
}
@Override
public void onRewardedVideoAdClosed() {
}
@Override
public void onRewarded(RewardItem rewardItem) {
}
@Override
public void onRewardedVideoAdLeftApplication() {
}
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
}
@Override
public void onRewardedVideoCompleted() {
}
});
}
use of com.google.android.gms.ads.InterstitialAd in project pixel-dungeon-remix by NYRDS.
the class Ads method initSaveAndLoadIntersitial.
public static void initSaveAndLoadIntersitial() {
if (googleAdsUsable() && Util.isConnectedToInternet()) {
{
Game.instance().runOnUiThread(new Runnable() {
@Override
public void run() {
if (mSaveAndLoadAd == null) {
mSaveAndLoadAd = new InterstitialAd(Game.instance());
mSaveAndLoadAd.setAdUnitId(Game.getVar(R.string.saveLoadAdUnitId));
requestNewInterstitial(mSaveAndLoadAd);
}
}
});
}
}
}
use of com.google.android.gms.ads.InterstitialAd in project pixel-dungeon-remix by NYRDS.
the class Ads method initEasyModeIntersitial.
private static void initEasyModeIntersitial() {
if (googleAdsUsable() && Util.isConnectedToInternet()) {
{
Game.instance().runOnUiThread(new Runnable() {
@Override
public void run() {
if (mEasyModeSmallScreenAd == null) {
mEasyModeSmallScreenAd = new InterstitialAd(Game.instance());
mEasyModeSmallScreenAd.setAdUnitId(Game.getVar(R.string.easyModeSmallScreenAdUnitId));
requestNewInterstitial(mEasyModeSmallScreenAd);
}
}
});
}
}
}
Aggregations