use of com.mopub.mobileads.MoPubInterstitial in project prebid-mobile-android by prebid.
the class XandrInterstitialMoPubDemoActivity 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);
final MoPubInterstitial mpInterstitial = new MoPubInterstitial(this, Constants.MOPUB_INTERSTITIAL_ADUNIT_ID_APPNEXUS);
mpInterstitial.setInterstitialAdListener(new MoPubInterstitial.InterstitialAdListener() {
@Override
public void onInterstitialLoaded(MoPubInterstitial interstitial) {
interstitial.show();
}
@Override
public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(XandrInterstitialMoPubDemoActivity.this, android.R.style.Theme_Material_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(XandrInterstitialMoPubDemoActivity.this);
}
builder.setTitle("Failed to load MoPub interstitial ad").setMessage("Error code: " + errorCode.toString()).setIcon(android.R.drawable.ic_dialog_alert).show();
}
@Override
public void onInterstitialShown(MoPubInterstitial interstitial) {
}
@Override
public void onInterstitialClicked(MoPubInterstitial interstitial) {
}
@Override
public void onInterstitialDismissed(MoPubInterstitial interstitial) {
}
});
int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
adUnit.setAutoRefreshPeriodMillis(millis);
adUnit.fetchDemand(mpInterstitial, new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
mpInterstitial.load();
}
});
}
use of com.mopub.mobileads.MoPubInterstitial in project prebid-mobile-android by prebid.
the class RubiconInterstitialMoPubDemoActivity 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);
final MoPubInterstitial mpInterstitial = new MoPubInterstitial(this, Constants.MOPUB_INTERSTITIAL_ADUNIT_ID_RUBICON);
mpInterstitial.setInterstitialAdListener(new MoPubInterstitial.InterstitialAdListener() {
@Override
public void onInterstitialLoaded(MoPubInterstitial interstitial) {
interstitial.show();
}
@Override
public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(RubiconInterstitialMoPubDemoActivity.this, android.R.style.Theme_Material_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(RubiconInterstitialMoPubDemoActivity.this);
}
builder.setTitle("Failed to load MoPub interstitial ad").setMessage("Error code: " + errorCode.toString()).setIcon(android.R.drawable.ic_dialog_alert).show();
}
@Override
public void onInterstitialShown(MoPubInterstitial interstitial) {
}
@Override
public void onInterstitialClicked(MoPubInterstitial interstitial) {
}
@Override
public void onInterstitialDismissed(MoPubInterstitial interstitial) {
}
});
int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
adUnit.setAutoRefreshPeriodMillis(millis);
adUnit.fetchDemand(mpInterstitial, new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
mpInterstitial.load();
refreshCount++;
RubiconInterstitialMoPubDemoActivity.this.resultCode = resultCode;
}
});
}
use of com.mopub.mobileads.MoPubInterstitial in project prebid-mobile-android by prebid.
the class RubiconInterstitialVideoMoPubDemoActivity 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;
final MoPubInterstitial mpInterstitial = new MoPubInterstitial(this, Constants.MOPUB_INTERSTITIAL_VIDEO_ADUNIT_ID_RUBICON);
mpInterstitial.setInterstitialAdListener(new MoPubInterstitial.InterstitialAdListener() {
@Override
public void onInterstitialLoaded(MoPubInterstitial interstitial) {
interstitial.show();
}
@Override
public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(RubiconInterstitialVideoMoPubDemoActivity.this, android.R.style.Theme_Material_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(RubiconInterstitialVideoMoPubDemoActivity.this);
}
builder.setTitle("Failed to load MoPub interstitial ad").setMessage("Error code: " + errorCode.toString()).setIcon(android.R.drawable.ic_dialog_alert).show();
}
@Override
public void onInterstitialShown(MoPubInterstitial interstitial) {
}
@Override
public void onInterstitialClicked(MoPubInterstitial interstitial) {
}
@Override
public void onInterstitialDismissed(MoPubInterstitial interstitial) {
}
});
int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
adUnit.setAutoRefreshPeriodMillis(millis);
adUnit.fetchDemand(mpInterstitial, new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
mpInterstitial.load();
}
});
}
use of com.mopub.mobileads.MoPubInterstitial in project prebid-mobile-android by prebid.
the class AdServerTest method startTest.
public void startTest() {
GeneralSettings generalSettings = SettingsManager.getInstance(mContext).getGeneralSettings();
AdServerSettings adServerSettings = SettingsManager.getInstance(mContext).getAdServerSettings();
PrebidServerSettings prebidServerSettings = SettingsManager.getInstance(mContext).getPrebidServerSettings();
switch(generalSettings.getAdSize()) {
case BANNER_300x250:
break;
case BANNER_300x600:
break;
case BANNER_320x50:
break;
case BANNER_320x100:
break;
case BANNER_320x480:
break;
case BANNER_728x90:
break;
}
mKeywords = createMapKeywords(adServerSettings.getBidPrice(), generalSettings.getAdSize(), generalSettings.getAdFormat(), prebidServerSettings.getPrebidServer());
if (adServerSettings.getAdServer() == AdServer.MOPUB) {
String keywords = createStringKeywords();
if (generalSettings.getAdFormat() == AdFormat.BANNER) {
AdSize adSize = generalSettings.getAdSize();
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(DimenUtil.convertPxToDp(mContext, adSize.getWidth()), DimenUtil.convertPxToDp(mContext, adSize.getHeight()));
mMoPubAd = new MoPubView(mContext);
mMoPubAd.setLayoutParams(layoutParams);
mMoPubAd.setAdUnitId(adServerSettings.getAdUnitId());
mMoPubAd.setAutorefreshEnabled(false);
mMoPubAd.setBannerAdListener(this);
mMoPubAd.setKeywords(keywords);
Networking.getRequestQueue(mContext).addRequestFinishedListener(mMoPubRequestFinishedListener);
mMoPubAd.loadAd();
} else if (generalSettings.getAdFormat() == AdFormat.INTERSTITIAL) {
mMoPubInterstitial = new MoPubInterstitial(mContext, adServerSettings.getAdUnitId());
mMoPubInterstitial.setInterstitialAdListener(this);
mMoPubInterstitial.setKeywords(keywords);
Networking.getRequestQueue(mContext).addRequestFinishedListener(mMoPubRequestFinishedListener);
mMoPubInterstitial.load();
}
} else if (adServerSettings.getAdServer() == AdServer.GOOGLE_AD_MANAGER) {
PublisherAdRequest adRequest = null;
if (generalSettings.getAdFormat() == AdFormat.BANNER) {
mGoogleAd = new PublisherAdView(mContext);
AdSize adSize = generalSettings.getAdSize();
mGoogleAd.setAdSizes(new com.google.android.gms.ads.AdSize(adSize.getWidth(), adSize.getHeight()));
mGoogleAd.setAdUnitId(adServerSettings.getAdUnitId());
mGoogleAd.setAdListener(mGoogleBannerListener);
} else if (generalSettings.getAdFormat() == AdFormat.INTERSTITIAL) {
mGoogleInterstitial = new PublisherInterstitialAd(mContext);
mGoogleInterstitial.setAdUnitId(adServerSettings.getAdUnitId());
mGoogleInterstitial.setAdListener(mGoogleInterstitialListener);
}
PublisherAdRequest.Builder adRequestBuilder = new PublisherAdRequest.Builder();
for (String key : mKeywords.keySet()) {
if (mKeywords.containsKey(key)) {
adRequestBuilder.addCustomTargeting(key, mKeywords.get(key));
}
}
adRequest = adRequestBuilder.build();
if (generalSettings.getAdFormat() == AdFormat.BANNER) {
mGoogleAd.loadAd(adRequest);
} else if (generalSettings.getAdFormat() == AdFormat.INTERSTITIAL) {
mGoogleInterstitial.loadAd(adRequest);
}
checkRequestForKeywordsAM(adRequest);
}
}
use of com.mopub.mobileads.MoPubInterstitial in project prebid-mobile-android by prebid.
the class UtilTest method testSupportedAdObject.
@Test
public void testSupportedAdObject() throws Exception {
MoPubView testView = new MoPubView(activity);
assertTrue(Util.supportedAdObject(testView));
assertFalse(Util.supportedAdObject(null));
MoPubInterstitial interstitial = new MoPubInterstitial(activity, "");
assertTrue(Util.supportedAdObject(interstitial));
AdManagerAdRequest request = new AdManagerAdRequest.Builder().build();
assertTrue(Util.supportedAdObject(request));
AdManagerAdRequest.Builder requestBuilder = new AdManagerAdRequest.Builder();
assertTrue(Util.supportedAdObject(requestBuilder));
Object object = new Object();
assertFalse(Util.supportedAdObject(object));
}
Aggregations