Search in sources :

Example 1 with InterstitialAd

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());
}
Also used : AdRequest(com.google.android.gms.ads.AdRequest) InterstitialAd(com.google.android.gms.ads.InterstitialAd) AdView(com.google.android.gms.ads.AdView) View(android.view.View) AdListener(com.google.android.gms.ads.AdListener)

Example 2 with InterstitialAd

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);
    }
}
Also used : AdRequest(com.google.android.gms.ads.AdRequest) InterstitialAd(com.google.android.gms.ads.InterstitialAd)

Example 3 with InterstitialAd

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() {
        }
    });
}
Also used : AdRequest(com.google.android.gms.ads.AdRequest) RewardedVideoAdListener(com.google.android.gms.ads.reward.RewardedVideoAdListener) RewardItem(com.google.android.gms.ads.reward.RewardItem) InterstitialAd(com.google.android.gms.ads.InterstitialAd) AdView(com.google.android.gms.ads.AdView)

Example 4 with InterstitialAd

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);
                    }
                }
            });
        }
    }
}
Also used : InterstitialAd(com.google.android.gms.ads.InterstitialAd)

Example 5 with InterstitialAd

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);
                    }
                }
            });
        }
    }
}
Also used : InterstitialAd(com.google.android.gms.ads.InterstitialAd)

Aggregations

InterstitialAd (com.google.android.gms.ads.InterstitialAd)22 Intent (android.content.Intent)12 SpannableStringBuilder (android.text.SpannableStringBuilder)10 View (android.view.View)9 AdListener (com.google.android.gms.ads.AdListener)9 SharedPreferences (android.content.SharedPreferences)8 Typeface (android.graphics.Typeface)8 TaskStackBuilder (android.app.TaskStackBuilder)6 FloatingActionButton (android.support.design.widget.FloatingActionButton)6 DatabaseHandler (io.praveen.typenote.SQLite.DatabaseHandler)6 Note (io.praveen.typenote.SQLite.Note)6 SuppressLint (android.annotation.SuppressLint)4 TargetApi (android.annotation.TargetApi)4 Notification (android.app.Notification)4 NotificationChannel (android.app.NotificationChannel)4 NotificationManager (android.app.NotificationManager)4 PendingIntent (android.app.PendingIntent)4 NotificationCompat (android.support.v4.app.NotificationCompat)4 RecyclerView (android.support.v7.widget.RecyclerView)4 AdRequest (com.google.android.gms.ads.AdRequest)4