-
Notifications
You must be signed in to change notification settings - Fork 6
Advanced integration of Inline Ad
To add a basic event listener to an AdInline
class, you can use an anonymous AdListener
implementation and add it to already initialized view like in example below.
adInline.setListener(new AdListener() {
@Override
public void onAdLoadSuccess(AdInline adInline) {
}
@Override
public void onAdLoadFail(AdInline adInline, String failError) {
}
});
For more control over the view, you can also use an AdStateListener
that reports additional view events.
mAdInline.setStateListener(new AdStateListener() {
@Override
public void onAdVisibilityChange(AdInline adInline, boolean isVisible) {
}
@Override
public void onAdOpen(AdInline adInline) {
}
@Override
public void onAdClose(AdInline adInline) {
}
});
You can also use an AdClickListener
that reports additional click view events.
adInline.setAdClickListener(new AdClickListener() {
@Override
public void onAdClick(AdInline adInline) {
}
@Override
public void onAdLeftApplication(AdInline adInline) {
}
});
You can also use an AdOverlayClickListener
that reports additional click view events.
adOverlay.setAdClickListener(new AdOverlay.AdOverlayClickListener() {
@Override
public void onAdClick(AdOverlay adOverlay) {
}
@Override
public void onAdLeftApplication(AdOverlay adOverlay) {
}
});
Smart ad size banners allow for the rendering of full width ads across different devices and orientations by "smartly" sizing ad units according to screen size. Three ad heights (in dp, density-independent pixel) are available:
32 - phones in landscape 50 - phones in portrait 90 - tablets in either orientation
More specifically, if the screen height of a device is between 400 and 720, an ad height of 50 is used in both orientations; for screen heights greater than 720, a 90 ad height is used.
When an image ad won't take up the entire allotted space for the banner, it will be centered.
To use banners with smart ad size, please use setAdSize(adSize)
method. For example:
adInline.setAdSize(new SmartAdSize());
From 2.11.0 version it is possible to specify width and height values for SmartAdSize. In this way you could show an ad in any size you want, no matter what is set in the server side.
adInline.setAdSize(new SmartAdSize(340, 210));
By default Adform SDK will try to open ad in a external browser. To open ad using in app window, you have to change adform sdk settings, please use this method:
AdformSDK.setOpenAdInInAppBrowser(true);
View can be shown with a set of animations by providing animation type. This can be done by using one of the following methods.
- By setting
setModalPresentationStyle(AdformEnum.AnimationType)
you'll be changing how the view will be animated when showing inexpand
state. - By setting
setBannerAnimationType(AdformEnum.AnimationType)
you'll be changing how the view will be animated when showing inbanner
(default) state.
You can select from a set of animations:
- AdformEnum.AnimationType.NO_ANIMATION - Ad is shown without an animation
- AdformEnum.AnimationType.SLIDE - Ad is shown with a slide animation
- AdformEnum.AnimationType.FADE - Ad is shown with a fade animation
By default, banner ad uses a SLIDE animation type.
This also can be done
AdInline
can enable/disable dimming when banner changes to expand state by using setDimOverlayEnabled(boolean)
.
The easiest way to add support for tablet and phone devices is to import different xml's for both screen types. To do that, in addition to default layout, add an xml layout for larger screen type, for e.g. add a folder layout-sw600dp
that targets tablet devices with smallest screen of 600dp and add an xml layout with different banner size to it.
<com.adform.sdk.pub.views.AdInline
android:id="@+id/ad_view"
mastertag_id="111111"
ad_width="728"
ad_height="90"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
For more information use the link below. http://developer.android.com/guide/practices/screens_support.html
The most common case to replace SDK with fallback image in case of failure is to add view into container.
<RelativeLayout
android:id="@+id/ad_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.adform.sdk.pub.views.AdInline
android:id="@+id/ad_view"
ad_height="50"
ad_width="320"
mastertag_id="111111"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
And change container background whenever there is a failure when loading an ad.
adInline.setListener(new AdListener() {
@Override
public void onAdLoadSuccess(AdInline adInline) { }
@Override
public void onAdLoadFail(AdInline adInline, String s) {
// Setting fallback image whenever ad fails to load
findViewById(R.id.ad_container).setBackgroundResource(R.drawable.ic_launcher);
}
});
The result will be a custom background, when ad fails to load.
Basic integrations
- Integrating Inline Ad
- Integrating Full Screen Overlay Ad
- Integrating Interstitial Ad
- Integrating Adhesion Ad
- Video Ad Integration
Advanced integrations
- Advanced integration of Inline Ad
- Advanced integration of Full Screen Overlay Ad
- Advanced integration of Interstitial Ad
- Advanced integration of Adhesion Ad
- Advanced integration of AdInline ListView
- Advanced integration of AdInline RecyclerView
- Instream video ads integration
Other
- Adding Custom Values
- Adding Keywords
- Adding Key Value Pairs
- Adding Search Words
- Location
- Security
- Ad Tags
- Header Bidding
- Changing ADX domain
- Specifying banner loading behaviour
- GDPR
- Logs
Mediation adapters
Plugins