3-3. Banner Ads
A banner is the most common form of advertising, displayed as a strip at the top or bottom of an app.
Create a banner ad.
Banner ads can be implemented either declaratively or imperatively.
XML declarative method.
Add the view where the banner ad will be displayed to the Layout.xml file in use.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical">
<!-- Banner View -->
<com.oneadmax.global.OAMBanner
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>Add the instance formed in XML to the code.
private OAMBanner banner;
@Override
protected void onCreate( Bundle savedInstanceState ){
...
banner = (OAMBanner)findViewById(R.id.banner);
...
}Imperative (code) method.
Without using XML, you can create a banner ad through the source code context using commands.
Set the banner PLACEMENT ID.
The banner PLACEMENT ID can be created in the ONE AdMax console.
Banner Size
There are three banner size options, and the value specified when creating the banner ad in the ONE AdMax console must be set accordingly.
Banner refresh interval
The configurable range is 15 to 300 seconds, and setting it to -1 disables the refresh.
Banner network schedule timeout setting
When loading banner ads, a timeout is set for each network (mediation partner). If an ad is not received within the specified time, it moves on to the next network.
Banner animation settings
Banner background color settings
You can fill the empty space in the view where the banner ad appears with an optimized background color that matches the ad.
Banner request
The load() API is called at the desired point when the banner should appear on the screen. Once the loading is complete, the onLoaded() event is triggered, and the banner will automatically appear on the screen.
Excessive calls to the load() API will result in a block.
Banner interruption
This is called when you want to stop the banner ad. Typically, it is called when the activity or fragment displaying the banner is destroyed.
Calling stop() when entering the onPause state may lead to missing click report data. Therefore, it is recommended to call it when the activity or fragment containing the banner view is destroyed.
Banner visibility status
Unlike other ad types, banners are automatically displayed on the screen once they are loaded. Therefore, you can use the following API to determine whether the banner is visible or not.
Banner event listener
Set up listeners for events that occur when loading a banner. The provided listeners and implementation examples are as follows:
ONE AdMax SDK Error CodesBanner onPause / onResume
In the onPause / onResume of the Activity or Fragment where the banner ad is displayed, you should call the banner's onPause / onResume. If onPause / onResume is not handled correctly, there may be missing report data when using third-party mediation. Therefore, it is recommended to implement it as shown below.
Banner Mediation
Banner ads support the use of some mediation platforms.
The settings must be configured before calling the banner's load() API.
The configuration values for supported mediations are as follows:
Banner sample code
Last updated