use of com.google.android.gms.ads.admanager.AdManagerAdView in project prebid-mobile-android by prebid.
the class RubiconBannerVideoGamDemoActivity 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)));
parameters.setPlacement(Signals.Placement.InBanner);
// parameters.setPlacement(new Signals.Placement(2));
VideoAdUnit adUnit = new VideoAdUnit("1001-1", 300, 250);
adUnit.setParameters(parameters);
this.adUnit = adUnit;
final AdManagerAdView amBanner = new AdManagerAdView(this);
amBanner.setAdUnitId(Constants.DFP_VAST_ADUNIT_ID_RUBICON);
amBanner.setAdSizes(new AdSize(300, 250));
FrameLayout adFrame = findViewById(R.id.adFrame);
adFrame.removeAllViews();
adFrame.addView(amBanner);
amBanner.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
AdViewUtils.findPrebidCreativeSize(amBanner, new AdViewUtils.PbFindSizeListener() {
@Override
public void success(int width, int height) {
amBanner.setAdSizes(new AdSize(width, height));
}
@Override
public void failure(@NonNull PbFindSizeError error) {
Log.d("MyTag", "error: " + error);
}
});
}
});
final AdManagerAdRequest.Builder builder = new AdManagerAdRequest.Builder();
// region PrebidMobile Mobile API 1.0 usage
int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
adUnit.setAutoRefreshPeriodMillis(millis);
adUnit.fetchDemand(builder, new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
AdManagerAdRequest request = builder.build();
amBanner.loadAd(request);
}
});
}
use of com.google.android.gms.ads.admanager.AdManagerAdView in project prebid-mobile-android by prebid.
the class XandrBannerGamDemoActivity 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);
BannerAdUnit adUnit = new BannerAdUnit(Constants.PBS_CONFIG_ID_300x250_APPNEXUS, 300, 250);
BannerBaseAdUnit.Parameters parameters = new BannerBaseAdUnit.Parameters();
parameters.setApi(Arrays.asList(Signals.Api.MRAID_2));
// parameters.setApi(Arrays.asList(new Signals.Api(5)));
adUnit.setParameters(parameters);
this.adUnit = adUnit;
// Util.enableAdditionalFunctionality(this.adUnit);
final AdManagerAdView amBanner = new AdManagerAdView(this);
amBanner.setAdUnitId(Constants.DFP_BANNER_ADUNIT_ID_ALL_SIZES_APPNEXUS);
amBanner.setAdSizes(new AdSize(300, 250));
FrameLayout adFrame = findViewById(R.id.adFrame);
adFrame.removeAllViews();
adFrame.addView(amBanner);
amBanner.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
AdViewUtils.findPrebidCreativeSize(amBanner, new AdViewUtils.PbFindSizeListener() {
@Override
public void success(int width, int height) {
amBanner.setAdSizes(new AdSize(width, height));
}
@Override
public void failure(@NonNull PbFindSizeError error) {
Log.d("MyTag", "error: " + error);
}
});
}
});
final AdManagerAdRequest.Builder builder = new AdManagerAdRequest.Builder();
// region PrebidMobile Mobile API 1.0 usage
int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
adUnit.setAutoRefreshPeriodMillis(millis);
adUnit.fetchDemand(builder, new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
AdManagerAdRequest request = builder.build();
amBanner.loadAd(request);
}
});
}
use of com.google.android.gms.ads.admanager.AdManagerAdView in project prebid-mobile-android by prebid.
the class ExtraTests method testSameConfigIdOnDifferentAdObjects.
@Test
public void testSameConfigIdOnDifferentAdObjects() throws Exception {
final ArrayList<AdUnit> adUnits = new ArrayList<AdUnit>();
final ArrayList<OnCompleteListener> spies = new ArrayList<>();
PrebidMobile.setApplicationContext(m.getActivity().getApplicationContext());
PrebidMobile.setPrebidServerAccountId("bfa84af2-bd16-4d35-96ad-31c6bb888df0");
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
mHandler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject1 = new MoPubView(m.getActivity());
adObject1.setAdUnitId(Constants.MOPUB_BANNER_ADUNIT_ID_320x50_APPNEXUS);
adObject1.setMinimumWidth(320);
adObject1.setMinimumHeight(50);
BannerAdUnit adUnit1 = new BannerAdUnit(Constants.PBS_CONFIG_ID_320x50_APPNEXUS, 320, 50);
adUnits.add(adUnit1);
OnCompleteListener l1 = new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
assertTrue(adObject1.getKeywords().contains("hb_pb:0.50"));
assertTrue(adObject1.getKeywords().contains("hb_cache_id:"));
FrameLayout adFrame = m.getActivity().findViewById(R.id.adFrame);
adFrame.addView(adObject1);
adObject1.loadAd();
}
};
l1 = spy(l1);
spies.add(l1);
adUnit1.fetchDemand(adObject1, l1);
AdManagerAdRequest.Builder builder = new AdManagerAdRequest.Builder();
final AdManagerAdRequest adObject2 = builder.build();
BannerAdUnit adUnit2 = new BannerAdUnit(Constants.PBS_CONFIG_ID_320x50_APPNEXUS, 320, 50);
adUnits.add(adUnit2);
OnCompleteListener l2 = new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
assertEquals(10, adObject2.getCustomTargeting().size());
assertTrue(adObject2.getCustomTargeting().keySet().contains("hb_pb"));
assertTrue(adObject2.getCustomTargeting().keySet().contains("hb_cache_id"));
assertEquals("0.50", adObject2.getCustomTargeting().getString("hb_pb"));
FrameLayout adFrame = m.getActivity().findViewById(R.id.adFrame);
AdManagerAdView adView = new AdManagerAdView(m.getActivity());
adView.setAdSizes(AdSize.BANNER);
adView.setAdUnitId(Constants.DFP_BANNER_ADUNIT_ID_ALL_SIZES_APPNEXUS);
adFrame.addView(adView);
adView.setId(1);
adView.loadAd(adObject2);
}
};
l2 = spy(l2);
spies.add(l2);
adUnit1.fetchDemand(adObject2, l2);
}
});
Thread.sleep(10000);
verify(spies.get(0), times(1)).onComplete(ResultCode.SUCCESS);
verify(spies.get(1), times(1)).onComplete(ResultCode.SUCCESS);
}
Aggregations