Banner Ad
Classes and Interfaces
IKShowWidgetAdListener Interface
This interface manages ad event callbacks for when ads are displayed, fail to display, or are clicked:
onAdShowed()
: Called when an ad is successfully shown.onAdShowFail(error: IKAdError)
: Called when there is an error displaying the ad.onAdClick()
: Optional method to handle ad click events.
Implementation Steps
Add IkmWidgetAdView 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 an 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.
Reference
com.ikame.android.sdk.widgets.IkmWidgetAdView#loadAd(String, IKShowWidgetAdListener)
Function Definition
fun loadAd(
screen: String,
listener: IKShowWidgetAdListener?
)
Parameters
screen
: considered as a unitId, our team will send you the screenAd list.listener
: IKShowWidgetAdListener Interface - Manages callbacks for displaying widget ads, focusing on events for ad load success and failures.
Sample Usage
Load Banner in Splash
To load an ad banner in splash screen , call the IkmWidgetAdView
loadSAWAd()
method and pass in an IKShowWidgetAdListener
to receive the loaded ad or any possible errors.
Function Definition
fun loadSAWAd(
listener: IKShowWidgetAdListener?
)
Parameters
listener
: IKShowWidgetAdListener Interface - Manages callbacks for displaying widget ads, focusing on events for ad load success and failures.
Sample Usage
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.
#Reference
com.ikame.android.sdk.widgets.IkmWidgetAdView#reCallLoadAd
#Function Definition
fun reCallLoadAd(listener: IKShowWidgetAdListener?)
Sample Usage
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.
Reference
com.ikame.android.sdk.widgets.IkmWidgetAdView#destroyAd()
Function Definition
fun destroyAd()
Sample usage
Classes and Interfaces
- IKShowWidgetAdListener Interface: Manages callbacks for displaying widget ads, focusing on events for ad load success and failures.