Skip to main content

Banner

Rectangular ads that can be fixed at the top or bottom of the screen.

Introduction

Images at the top, middle, or bottom of the app. Refer to the ad sizes supported by Hisavana ad source: 20:3, 3:2, effect diagrams as follows:

20:33:2

We recommend that you download and experience the Mediation Demo to gain a more intuitive and in-depth understanding of the SDK's features and usage. Through the Demo, you can quickly get started and explore its application in real-world scenarios.

Building Components

Create TBannerView object.

// Please add TBannerView in the parent layout XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e8e8e8"
android:orientation="vertical">
<com.hisavana.mediation.ad.TBannerView
android:id="@+id/banner_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:visibility="gone"/>
</RelativeLayout>
// Bind the view in XML layout
TBannerView tBannerView = findViewById(R.id.banner_view);

or

// Manually create TBannerView object and "add to parent layout"
TBannerView tBannerView = new TBannerView(this);

Load Ads

Please configure the corresponding parameters and callback listeners. Be sure to carefully review the documentation for the applicable ad placement types in relevant callbacks to avoid integration discrepancies.

// Set banner size (effective for non-Yandex), refer to "Sizes and Types" below
tBannerView.setAdSize(BannerSize.SIZE_320x50);

/**
* Optional, only supports ad sources "Liftoff (Vungle)", "Yandex", set banner ad width and height properties
*
* "Liftoff (Vungle)": Default uses "Sizes and Types"; if setting width and height uses adaptive width/height, unit: dp
*
* "Yandex": Width defaults to screen width, unit: dp; max height if not set defaults to adaptive sticky height, otherwise adaptive inline, unit: dp
*/
// tBannerView.setCustomSizeForYandexAndLiftoff(adWith, adHeight);

// Optional, if you need to integrate admob collapsing banner, set this property. Other types refer to "Sizes and Types" below
// tBannerView.setBannerType(IBannerType.BANNER_TYPE_TOP_FOLD);

// "banner_id" is the Banner ad unit ID
tBannerView.setAdUnitId("banner_id");

/**
* Optional
* For applications that need to track ad scenario reach, you can set scenario values yourself
* Main purpose is to track current ad scenario utilization rate, first parameter custom scenario name, second parameter ad quantity
*/
tBannerView.enterScene("banner_scene_name", 1);

// Build ad request body
TAdRequestBody tAdRequest = new TAdRequestBody.AdRequestBodyBuild()
.setAdListener(new TAdAlliance())
.build();
// Set ad request body
tBannerView.setRequestBody(tAdRequest);
// After loading ads, return the optimal ad callback within the set waiting time
tBannerView.loadAd();

// Ad listener, monitors ad load completion (fill), display, click, exception, close actions callbacks
private static class TAdAlliance extends TAdListener {

// Load completion callback (applicable ad units: all ad units)
@Override
public void onLoad() {
// Ad loaded callback
}

// Exception callback (applicable ad units: all ad units)
@Override
public void onError(TAdErrorCode errorCode) {
// Ad failed callback
}

// Display callback (applicable ad units: Splash, Interstitial, Banner, Reward)
@Override
public void onShow(int source) {
// Ad show callback
}

// Click callback (applicable ad units: Splash, Interstitial, Banner, Reward)
@Override
public void onClicked(int source) {
// Ad click callback
}

// Close callback (applicable ad units: Splash, Interstitial, Banner, Reward)
@Override
public void onClosed(int source) {
// Ad close callback
}

// Display failure callback (applicable ad units: all ad units)
@Override
public void onShowError(TAdErrorCode errorCode) {
// Ad show failed callback
}
}

Reminder: source represents the ad source, please refer to Ad Source Correlation Table; for example: if this ad fill display is pangle ad, then source=6.

Display Ads

Please display the TBannerView object.

// Banner ads automatically display after loading and filling, if you hid the view please check view visibility, if the view is dynamically added please check if it has been added to parent layout
tBannerView.setVisibility(View.VISIBLE);

Destroy Ads

Please recycle ads promptly, otherwise the App may experience memory leaks.

@Override
public void onClosed(int source) {
// After the ad is closed, if you no longer continue to use the view and ad object, it is recommended that you release the view and ad object promptly to avoid memory leaks.
if (tBannerView != null) {
tBannerView.destroy();
tBannerView.removeAllViews();
removeView(tBannerView);
tBannerView = null;
}
}
// After exiting the ad scenario, please destroy the ad object.
@Override
protected void onDestroy() {
super.onDestroy();
if (tBannerView != null) {
tBannerView.destroy();
tBannerView.removeAllViews();
removeView(tBannerView);
tBannerView = null;
}
}

// Remove ad view
private void removeView(View v) {
if (v == null) return;
ViewParent viewGroup = v.getParent();
if (viewGroup instanceof ViewGroup) {
((ViewGroup) viewGroup).removeView(v);
}
}

Other APIs

API CallDescription
tBannerView.resume()Call in lifecycle
tBannerView.pause()Call in lifecycle

Reminder: After adding Mintergral ad source, when the system's onResume, onPause are called, the media needs to actively call the above two lifecycle callback methods, which can reduce the number of errors generated by the Mintergral ad source.

Sizes and Types

TBannerView Is the placeholder View for Banner ads, needs width and height at least larger than TAdBannerSize dimensions, otherwise ad display may have errors. When using admob's adaptive banner, Banner Size needs to use 320 * 50

Banner Size (Applicable to non-Yandex)

BannerSize constantSize dp (Unit: dp)
SIZE_320x50320*50
SIZE_320x90320*90
SIZE_320x100320*100
SIZE_320x250320*250

Banner Types (Applicable to Admob)

IBannerType constantBanner Type
BANNER_TYPE_TOP_FOLDTop fold banner ad
BANNER_TYPE_BOTTOM_FOLDBottom fold banner ad
BANNER_TYPE_NORMALNormal banner ad