use of org.prebid.mobile.InterstitialAdUnit in project prebid-mobile-android by prebid.
the class SdkTest method setupPrebid.
private void setupPrebid() {
GeneralSettings generalSettings = SettingsManager.getInstance(mContext).getGeneralSettings();
PrebidServerSettings prebidServerSettings = SettingsManager.getInstance(mContext).getPrebidServerSettings();
setPrebidTargetingParams();
if (generalSettings.getAdFormat() == AdFormat.BANNER) {
AdSize adSize = generalSettings.getAdSize();
mAdUnit = new BannerAdUnit(prebidServerSettings.getConfigId(), adSize.getWidth(), adSize.getHeight());
} else if (generalSettings.getAdFormat() == AdFormat.INTERSTITIAL) {
mAdUnit = new InterstitialAdUnit(prebidServerSettings.getConfigId());
}
PrebidMobile.setPrebidServerAccountId(prebidServerSettings.getAccountId());
switch(prebidServerSettings.getPrebidServer()) {
case APPNEXUS:
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
break;
case RUBICON:
PrebidMobile.setPrebidServerHost(Host.RUBICON);
break;
case CUSTOM:
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
Host.CUSTOM.setHostUrl(buildCustomServerEndpoint(prebidServerSettings.getCustomPrebidServerUrl()));
break;
}
if (mListener != null) {
mListener.onAdUnitRegistered();
}
}
use of org.prebid.mobile.InterstitialAdUnit 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 org.prebid.mobile.InterstitialAdUnit 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;
}
});
}
Aggregations