Display AdropBanner
Initialize AdropBanner
with ad unit ID, then load ad. add banner to area you want when onAdReceived
callback
val adContainer: FrameLayout // your Ad container
val banner: AdropBanner = AdropBanner(applicationContext, unitId)
banner.listener = object : AdropBannerListener {
override fun onAdReceived(banner: AdropBanner) {
adContainer.removeAllViews()
adContainer.addView(banner)
}
override fun onAdClicked(banner: AdropBanner) {
Log.d("Adrop", "${banner.getUnitId()}, onAdClicked")
// "{unitId}, onAdClicked"
}
override fun onAdFailedToReceive(banner: AdropBanner, error: AdropErrorCode) {
removeView(banner)
}
}
// request ad to server
banner.load()
FrameLayout adContainer // your Ad container
AdropBanner banner = new AdropBanner(getApplicationContext(), unitId);
banner.setListener(new AdropBannerListener() {
@Override
public void onAdReceived(@NonNull AdropBanner banner) {
adContainer.removeAllViews();
adContainer.addView(banner);
}
@Override
public void onAdClicked(@NonNull AdropBanner banner) {
Log.d("Adrop", banner.getUnitId() + ", onAdClicked");
// "{unitId}, onAdClicked"
}
@Override
public void onAdFailedToReceive(@NonNull AdropBanner banner, @NonNull AdropErrorCode error) {
removeView(banner);
}
});
// request ad to server
banner.load();
Destroy
When you are done showing your AdropBanner, you should destroy it so that the ad is properly garbage collected.
Last updated