Search in sources :

Example 1 with AdManagerInterstitialAd

use of com.google.android.gms.ads.admanager.AdManagerInterstitialAd in project prebid-mobile-android by prebid.

the class PublisherInterstitialAdWrapperTest method onGamAdLoadedAppEventExpected_NotifyLoadedListener.

@Test
public void onGamAdLoadedAppEventExpected_NotifyLoadedListener() {
    final AdManagerInterstitialAdLoadCallback listener = getAdLoadCallback();
    final AdManagerInterstitialAd mock = mock(AdManagerInterstitialAd.class);
    listener.onAdLoaded(mock);
    verify(mMockListener, times(1)).onEvent(AdEvent.LOADED);
}
Also used : AdManagerInterstitialAdLoadCallback(com.google.android.gms.ads.admanager.AdManagerInterstitialAdLoadCallback) AdManagerInterstitialAd(com.google.android.gms.ads.admanager.AdManagerInterstitialAd) Test(org.junit.Test)

Example 2 with AdManagerInterstitialAd

use of com.google.android.gms.ads.admanager.AdManagerInterstitialAd in project prebid-mobile-android by prebid.

the class XandrInterstitialGamDemoActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
    PrebidMobile.setPrebidServerAccountId(Constants.PBS_ACCOUNT_ID_APPNEXUS);
    adUnit = new InterstitialAdUnit(Constants.PBS_CONFIG_ID_INTERSTITIAL_APPNEXUS);
    int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
    adUnit.setAutoRefreshPeriodMillis(millis);
    final AdManagerAdRequest.Builder builder = new AdManagerAdRequest.Builder();
    adUnit.fetchDemand(builder, new OnCompleteListener() {

        @Override
        public void onComplete(ResultCode resultCode) {
            AdManagerAdRequest request = builder.build();
            AdManagerInterstitialAd.load(XandrInterstitialGamDemoActivity.this, Constants.DFP_INTERSTITIAL_ADUNIT_ID_APPNEXUS, request, new AdManagerInterstitialAdLoadCallback() {

                @Override
                public void onAdLoaded(@NonNull AdManagerInterstitialAd adManagerInterstitialAd) {
                    super.onAdLoaded(adManagerInterstitialAd);
                    adManagerInterstitialAd.show(XandrInterstitialGamDemoActivity.this);
                }

                @Override
                public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                    super.onAdFailedToLoad(loadAdError);
                    AlertDialog.Builder builder;
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        builder = new AlertDialog.Builder(XandrInterstitialGamDemoActivity.this, android.R.style.Theme_Material_Dialog_Alert);
                    } else {
                        builder = new AlertDialog.Builder(XandrInterstitialGamDemoActivity.this);
                    }
                    builder.setTitle("Failed to load AdManager interstitial ad").setMessage("Error: " + loadAdError.toString()).setIcon(android.R.drawable.ic_dialog_alert).show();
                }
            });
        }
    });
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) LoadAdError(com.google.android.gms.ads.LoadAdError) AdManagerInterstitialAdLoadCallback(com.google.android.gms.ads.admanager.AdManagerInterstitialAdLoadCallback) AdManagerInterstitialAd(com.google.android.gms.ads.admanager.AdManagerInterstitialAd) OnCompleteListener(org.prebid.mobile.OnCompleteListener) NonNull(androidx.annotation.NonNull) AdManagerAdRequest(com.google.android.gms.ads.admanager.AdManagerAdRequest) ResultCode(org.prebid.mobile.ResultCode) InterstitialAdUnit(org.prebid.mobile.InterstitialAdUnit)

Example 3 with AdManagerInterstitialAd

use of com.google.android.gms.ads.admanager.AdManagerInterstitialAd in project prebid-mobile-android by prebid.

the class RubiconInterstitialGamDemoActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    PrebidMobile.setPrebidServerHost(Host.RUBICON);
    PrebidMobile.setPrebidServerAccountId(Constants.PBS_ACCOUNT_ID_RUBICON);
    PrebidMobile.setStoredAuctionResponse(Constants.PBS_STORED_RESPONSE_300x250_RUBICON);
    adUnit = new InterstitialAdUnit(Constants.PBS_CONFIG_ID_INTERSTITIAL_RUBICON);
    int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
    adUnit.setAutoRefreshPeriodMillis(millis);
    final AdManagerAdRequest.Builder builder = new AdManagerAdRequest.Builder();
    adUnit.fetchDemand(builder, new OnCompleteListener() {

        @Override
        public void onComplete(ResultCode resultCode) {
            AdManagerAdRequest request = builder.build();
            AdManagerInterstitialAd.load(RubiconInterstitialGamDemoActivity.this, Constants.DFP_INTERSTITIAL_ADUNIT_ID_RUBICON, request, new AdManagerInterstitialAdLoadCallback() {

                @Override
                public void onAdLoaded(@NonNull AdManagerInterstitialAd adManagerInterstitialAd) {
                    super.onAdLoaded(adManagerInterstitialAd);
                    adManagerInterstitialAd.show(RubiconInterstitialGamDemoActivity.this);
                }

                @Override
                public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                    super.onAdFailedToLoad(loadAdError);
                    AlertDialog.Builder builder;
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        builder = new AlertDialog.Builder(RubiconInterstitialGamDemoActivity.this, android.R.style.Theme_Material_Dialog_Alert);
                    } else {
                        builder = new AlertDialog.Builder(RubiconInterstitialGamDemoActivity.this);
                    }
                    builder.setTitle("Failed to load AdManager interstitial ad").setMessage("Error: " + loadAdError.toString()).setIcon(android.R.drawable.ic_dialog_alert).show();
                }
            });
            refreshCount++;
            RubiconInterstitialGamDemoActivity.this.resultCode = resultCode;
        }
    });
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) LoadAdError(com.google.android.gms.ads.LoadAdError) AdManagerInterstitialAdLoadCallback(com.google.android.gms.ads.admanager.AdManagerInterstitialAdLoadCallback) AdManagerInterstitialAd(com.google.android.gms.ads.admanager.AdManagerInterstitialAd) OnCompleteListener(org.prebid.mobile.OnCompleteListener) NonNull(androidx.annotation.NonNull) AdManagerAdRequest(com.google.android.gms.ads.admanager.AdManagerAdRequest) ResultCode(org.prebid.mobile.ResultCode) InterstitialAdUnit(org.prebid.mobile.InterstitialAdUnit)

Example 4 with AdManagerInterstitialAd

use of com.google.android.gms.ads.admanager.AdManagerInterstitialAd in project prebid-mobile-android by prebid.

the class RubiconInterstitialVideoGamDemoActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    PrebidMobile.setPrebidServerHost(Host.RUBICON);
    PrebidMobile.setPrebidServerAccountId(Constants.PBS_ACCOUNT_ID_RUBICON);
    PrebidMobile.setStoredAuctionResponse(Constants.PBS_STORED_RESPONSE_VAST_RUBICON);
    VideoBaseAdUnit.Parameters parameters = new VideoBaseAdUnit.Parameters();
    parameters.setMimes(Arrays.asList("video/mp4"));
    parameters.setProtocols(Arrays.asList(Signals.Protocols.VAST_2_0));
    // parameters.setProtocols(Arrays.asList(new Signals.Protocols(2)));
    parameters.setPlaybackMethod(Arrays.asList(Signals.PlaybackMethod.AutoPlaySoundOff));
    // parameters.setPlaybackMethod(Arrays.asList(new Signals.PlaybackMethod(2)));
    VideoInterstitialAdUnit adUnit = new VideoInterstitialAdUnit("1001-1");
    adUnit.setParameters(parameters);
    this.adUnit = adUnit;
    int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
    adUnit.setAutoRefreshPeriodMillis(millis);
    final AdManagerAdRequest.Builder builder = new AdManagerAdRequest.Builder();
    adUnit.fetchDemand(builder, new OnCompleteListener() {

        @Override
        public void onComplete(ResultCode resultCode) {
            AdManagerAdRequest request = builder.build();
            AdManagerInterstitialAd.load(RubiconInterstitialVideoGamDemoActivity.this, Constants.DFP_VAST_ADUNIT_ID_RUBICON, request, new AdManagerInterstitialAdLoadCallback() {

                @Override
                public void onAdLoaded(@NonNull AdManagerInterstitialAd adManagerInterstitialAd) {
                    super.onAdLoaded(adManagerInterstitialAd);
                    adManagerInterstitialAd.show(RubiconInterstitialVideoGamDemoActivity.this);
                }

                @Override
                public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                    super.onAdFailedToLoad(loadAdError);
                    AlertDialog.Builder builder;
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        builder = new AlertDialog.Builder(RubiconInterstitialVideoGamDemoActivity.this, android.R.style.Theme_Material_Dialog_Alert);
                    } else {
                        builder = new AlertDialog.Builder(RubiconInterstitialVideoGamDemoActivity.this);
                    }
                    builder.setTitle("Failed to load AdManager interstitial ad").setMessage("Error: " + loadAdError.toString()).setIcon(android.R.drawable.ic_dialog_alert).show();
                }
            });
        }
    });
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) LoadAdError(com.google.android.gms.ads.LoadAdError) VideoInterstitialAdUnit(org.prebid.mobile.VideoInterstitialAdUnit) AdManagerInterstitialAdLoadCallback(com.google.android.gms.ads.admanager.AdManagerInterstitialAdLoadCallback) AdManagerInterstitialAd(com.google.android.gms.ads.admanager.AdManagerInterstitialAd) OnCompleteListener(org.prebid.mobile.OnCompleteListener) NonNull(androidx.annotation.NonNull) VideoBaseAdUnit(org.prebid.mobile.VideoBaseAdUnit) AdManagerAdRequest(com.google.android.gms.ads.admanager.AdManagerAdRequest) ResultCode(org.prebid.mobile.ResultCode)

Aggregations

AdManagerInterstitialAd (com.google.android.gms.ads.admanager.AdManagerInterstitialAd)4 AdManagerInterstitialAdLoadCallback (com.google.android.gms.ads.admanager.AdManagerInterstitialAdLoadCallback)4 NonNull (androidx.annotation.NonNull)3 AlertDialog (androidx.appcompat.app.AlertDialog)3 LoadAdError (com.google.android.gms.ads.LoadAdError)3 AdManagerAdRequest (com.google.android.gms.ads.admanager.AdManagerAdRequest)3 OnCompleteListener (org.prebid.mobile.OnCompleteListener)3 ResultCode (org.prebid.mobile.ResultCode)3 InterstitialAdUnit (org.prebid.mobile.InterstitialAdUnit)2 Test (org.junit.Test)1 VideoBaseAdUnit (org.prebid.mobile.VideoBaseAdUnit)1 VideoInterstitialAdUnit (org.prebid.mobile.VideoInterstitialAdUnit)1