Inline Adaptive Banner Ads
The Inline Banner ad is implemented similarly to a standard banner ad. The format of the ad is dynamically chosen based on the screen
id provided when loading the ad.
Here is an example of what a inline adaptive banner ad looks like:
![]() |
---|
Inline Banner Format |
Add ad view to the layout
The first step in displaying a banner ad is to place an IkmWidgetAdView
in the layout for the Activity or Fragment where the ad is to be shown.
<com.ikame.android.sdk.widgets.IkmWidgetAdView
android:id="@+id/adsView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ikwad_preview_layout="@layout/shimmer_loading_banner" />
Load ad
Once the IkmWidgetAdView
is in place, the next step is to load an ad. That’s done with the loadAd() method in the IkmWidgetAdView
class.The ad is identified by a specific screen, which acts as the ad unit ID. The IKShowWidgetAdListener
listener handles the events that occur during the ad’s display process, such as successfully showing the ad or encountering a failure.
fun loadAd(screen: String, adListener: IKShowWidgetAdListener?)
Parameters:
-
screen
: considered as a unitId, our team will send you the screenAd list. -
adListener
: TheIKShowWidgetAdListener
interface is designed to handle the events related to the display of widget ads. It provides callbacks for various stages of ad display, including when ads are shown, fail to show, or are clicked.-
onAdShowed()
: Called when an ad is successfully displayed. This method is used to trigger any follow-up actions once the ad is shown. -
onAdShowFail(error: IKAdError)
: Invoked when there is a failure in displaying the ad. It takes anIKAdError
object as a parameter, which contains details about what caused the failure. -
onAdClick()
: Triggered when an ad is clicked by the user. This method can be used to handle user interaction with the ad.
-
Example
Recall load current ad
When IkmWidgetAdView
has successfully loaded an Ad, if you want to show another ad at this location. Please use the following function to avoid losing old Ads that have been displayed.
fun reCallLoadAd(listener: IKShowWidgetAdListener?)
Parameters:
-
listener
: The IKShowWidgetAdListener interface is designed to handle the events related to the display of widget ads. It provides callbacks for various stages of ad display, including when ads are shown, fail to show, or are clicked.-
onAdShowed()
: Called when an ad is successfully displayed. This method is used to trigger any follow-up actions once the ad is shown. -
onAdShowFail(error: IKAdError)
: Invoked when there is a failure in displaying the ad. It takes anIKAdError
object as a parameter, which contains details about what caused the failure. -
onAdClick()
: Triggered when an ad is clicked by the user. This method can be used to handle user interaction with the ad.
-
Example
Destroy ad
In certain scenarios, IkmWidgetAdView
can be prone to memory leaks. Therefore, it is essential to destroy the ad when your Fragment or Activity is destroyed to manage resources properly.
fun destroyAd()